diff --git a/.gitignore b/.gitignore index 001d99a..da7e323 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ vscode-bitbake-build/ documentation/_build/ documentation/oe-logs documentation/oe-workdir -__pycache__ \ No newline at end of file +__pycache__ +.venv/ diff --git a/.vscode/extensions.json b/.vscode/extensions.json index c39b0c8..ac5a5fb 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,6 +1,10 @@ { "recommendations": [ "ms-vscode.makefile-tools", - "timonwong.shellcheck" + "timonwong.shellcheck", + "eugenwiens.bitbake", + "kweihmann.oelint-vscode", + "lextudio.restructuredtext", + "trond-snekvik.simple-rst" ] } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index b6d0c36..86af9a6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,7 +3,10 @@ "**/build/cache/**": true, "**/build/downloads/**": true, "**/build/sstate-cache/**": true, - "**/build/tmp/**": true + "**/build/tmp/**": true, + "**/documentation/_build/**": true, + "**/build/workspace": true }, - "python.formatting.provider": "black" + "python.formatting.provider": "black", + "editor.rulers": [80,100,120] } \ No newline at end of file diff --git a/documentation/components/optional/index.rst b/documentation/components/optional/index.rst index 1bd8a95..20cb7d2 100644 --- a/documentation/components/optional/index.rst +++ b/documentation/components/optional/index.rst @@ -12,3 +12,4 @@ CoreOS Optional Components Network Manager: NetworkManager SSH Server: OpenSSH Container: Podman + CoreOS Installer diff --git a/documentation/components/optional/installer.rst b/documentation/components/optional/installer.rst new file mode 100644 index 0000000..b3858e4 --- /dev/null +++ b/documentation/components/optional/installer.rst @@ -0,0 +1,35 @@ +.. index:: COREOS_INSTALLER + +CoreOS Installer +**************** + +The CoreOS installer is a set of script running on the target and a +corresponding bitbake image that is used into the bootstrap process of CoreOS. + +coreos-image-installer +====================== + +The CoreOS installer image is a single binary EFI file that include a kernel, +device tree and an initramfs with all the tools needed to install CoreOS. + +An installer image is automatically built in parallel of a normal image. +This can be deactivated by setting `COREOS_IMAGE_GENERATE_INSTALLER` to 0. + +The installer image build by default only a single EFI binary named +coreos-installer-MACHINE.efi. An SDCard image can be generate if +`COREOS_INSTALLER_WKS_FILE` is set to a wks file. + +coreos-installer +================ + +The coreos-installer recipe installs some script that is used at startup +to automatically format the internal emmc of the device. It also contains +a swupdate configuration file to setup swupdate correctly for that use case. + +coreos-installer-config +======================= + +The coreos-installer-config recipe installs device specific configuration file +used by the coreos-installer. This includes the partitionner config file. Distro +and project based on CoreOS can change the partionning scheme or partition size +by installing their own version of this package using a `bbappend file`. diff --git a/documentation/hardware/beaglebone.rst b/documentation/hardware/beaglebone.rst new file mode 100644 index 0000000..10f6eda --- /dev/null +++ b/documentation/hardware/beaglebone.rst @@ -0,0 +1,61 @@ +.. _beaglebone: + +********** +BeagleBone +********** + +.. important:: + + The BeagleBone target uses an old TI AM3358 ARM 32 BIT CPU. This processor + of the AM335x family is used in a lot of current and legacy device at + Hirschmann and NetModule. Thus we only support this target to ensure + that our architecture is working on older architecture too. + +CoreOS build instruction +======================== + +.. code-block:: + + MACHINE=beaglebone bitbake coreos-image-all-features + cd tmp/deploy/images/beaglebone + +.. list-table:: Image artifacts for BeagleBone + :widths: 25 75 + :header-rows: 1 + + * - Filename + - Description + * - -beaglebone.swu + - System image bundle used by the CoreOS installer or the CoreOS updater + * - -beaglebone.wic.xz + - System image for SDCard + * - coreos-image-installer-beaglebone.wic.xz + - CoreOS installer image for SD Card + +.. hint:: + + Only the .swu image is need if you have already a working installation of CoreOS + running on the board that you want to update. + +CoreOS Pre-installation guide +============================= + +If you want to use the internal emmc storage as boot target, you will need to +flash coreos-image-installer-beaglebone.wic.xz to your SDCard using bmaptool. + +If you want to use the sdcard as boot target, you will need to flash +-beaglebone.wic.xz to your SDCard using bmaptool. + +By default the board boot on the internal emmc storage. To boot with a SDCard +instead, you will need to push the S2 button (boot switch) while powering up the +board. + +.. image:: beaglebone/beaglebone-s2-switch.png + +Serial access is available on the 5-pin header. See +`this page `_ for +more info on the serial connector. + +Now that you have the installer running, CoreOS can be installed by following +the :ref:`generic installation manual` using the SDCard +mehtod. diff --git a/documentation/hardware/beaglebone/beaglebone-s2-switch.png b/documentation/hardware/beaglebone/beaglebone-s2-switch.png new file mode 100644 index 0000000..d99bcdf Binary files /dev/null and b/documentation/hardware/beaglebone/beaglebone-s2-switch.png differ diff --git a/documentation/hardware/netmodule-hw34.rst b/documentation/hardware/netmodule-hw34.rst new file mode 100644 index 0000000..cfccf60 --- /dev/null +++ b/documentation/hardware/netmodule-hw34.rst @@ -0,0 +1,126 @@ +.. _netmodule-hw34: + +******************************* +NetModule HW34 (XG900 A-Sample) +******************************* + +.. important:: + + netmodule-hw34 support is currently only available on the features branch + feat/netmodule-bsp + +.. image:: netmodule-hw34/hw34.png + +CoreOS build instruction +======================== + +.. code-block:: + + MACHINE=netmodule-hw34 bitbake coreos-image-all-features + cd tmp/deploy/images/netmodule-hw34 + +.. list-table:: Image artifacts for NetModule HW32 + :widths: 25 75 + :header-rows: 1 + + * - Filename + - Description + * - -netmodule-hw34.swu + - System image bundle used by the CoreOS installer or the CoreOS updater + * - coreos-installer-netmodule-hw34.efi + - CoreOS installer bundled in a single EFI binary + * - tiboot3.bin + - SPL Bootloader for the wakeup domain (arm32 R5 core) + * - tispl.bin + - SPL bootloader for the main domain (aarch64 main core) + * - u-boot.bin + - Third stage bootloader the main domain (aarch64 main core) + +.. hint:: + + Only the .swu image is need if you have already a working installation of CoreOS + running on the board that you want to update. + +CoreOS Pre-installation guide +============================= + +The CoreOS installation process expect a working EFI firmware based on u-boot +running on the board. + +For board that have no firmware or a defect firmware, we can provide the firmware by +booting over USB. + +First, we need to put the board in USB Boot mode by modifying the dip-switch +on the back of the board: + +.. code-block:: + + ON + S500 ▄ ▀ ▄ ▀ ▄ ▄ ▄ ▄ + 1 2 3 4 5 6 7 8 + +.. hint:: + + Unflashed board or board without a valid tiboot3.bin image will default to + USB boot mode, so settings the dip-switch may be skipped in this case. + +Then you need to populate the jumper X600 near the USB port: + +.. image:: netmodule-hw34/hw34-usb-device.png + +Then power-up the board by first apply 12V throug the main connector, then +connect a USB-C cable. Console access to the board can be accessed using the +serial port on the main connector. + + +.. important:: + + When removing the power, ensure that the USB cable is removed first. Otherwise + the processor will not get shutdown properly + + +Now you should see the board from you computer: + +.. code-block:: sh + + lsusb | grep DFU + Bus 003 Device 048: ID 0451:6165 Texas Instruments, Inc. AM64x DFU + +Now we start downloading the bootloaders into RAM by using dfu-utils: + +.. code-block:: sh + + dfu-util -D tiboot3.bin -a 0 + dfu-util -D tispl.bin -a 0 + + # Eject and start execution of tispl + dfu-util -e -a 0 + dfu-util -D u-boot.img -a 1 + + # Eject ans tart of u-boot.img + dfu-util -e -a 1 + +.. hint:: + + The firmware was uploaded to the RAM, thus will not survice a reboot. + + +Now that we have a firmware running, CoreOS can be installed by following +the :ref:`generic installation manual`. + + +CoreOS Post-Installation +======================== + +When the installation of CoreOS is done, power down the board by first +removing the USB-C cable then the main power. + +Now, put the board back in emmc boot mode: + +.. code-block:: + + ON + S500 ▀ ▄ ▄ ▀ ▄ ▄ ▄ ▄ + 1 2 3 4 5 6 7 8 + +Then power-up the board again and CoreOS should boot. diff --git a/documentation/hardware/netmodule-hw34/hw34-usb-device.png b/documentation/hardware/netmodule-hw34/hw34-usb-device.png new file mode 100644 index 0000000..891e473 Binary files /dev/null and b/documentation/hardware/netmodule-hw34/hw34-usb-device.png differ diff --git a/documentation/hardware/netmodule-hw34/hw34.png b/documentation/hardware/netmodule-hw34/hw34.png new file mode 100644 index 0000000..4ee69b2 Binary files /dev/null and b/documentation/hardware/netmodule-hw34/hw34.png differ diff --git a/documentation/hardware/overview.rst b/documentation/hardware/overview.rst new file mode 100644 index 0000000..cce0fa4 --- /dev/null +++ b/documentation/hardware/overview.rst @@ -0,0 +1,33 @@ +****************** +Supported Hardware +****************** + +.. _Hardware Overview: +.. list-table:: Supported BitBake MACHINE + :widths: 25 75 25 + :header-rows: 1 + + * - BitBake MACHINE + - Compatible hardware + - Documentation + * - cn9131-bldn-mbv + - Falcon A3 Sample + - + * - netmodule-hw34 + - NetModule HW34 (XG900 Sample) + - :ref:`🔗 links ` + * - cn9130-cf-pro + - Solidrun cn9130-cf-pro + - + * - beaglebone + - Beaglebone, Beaglebone Black, Beaglebone Green + - :ref:`🔗 links ` + * - vm-x64 + - Virtual Machine + - + +.. hint:: + + Please contact the CoreOS team when starting a new project based on CoreOS + or want to contribute the hardware support for an existing Hardware. + diff --git a/documentation/index.rst b/documentation/index.rst index a90d640..fa6029f 100644 --- a/documentation/index.rst +++ b/documentation/index.rst @@ -28,20 +28,28 @@ same structures. .. toctree:: :maxdepth: 1 - :caption: Software Components - - Core Components - Optional Components + :caption: Supported Hardware + Overview + NetModule HW34 (XG900 Sample) + BeagleBone .. toctree:: :maxdepth: 1 :caption: Manuals + Installation Manual Reference Manual Boot Concepts Best Practices +.. toctree:: + :maxdepth: 1 + :caption: Software Components + + Core Components + Optional Components + .. toctree:: :maxdepth: 1 :caption: Indexes diff --git a/documentation/installation/index.rst b/documentation/installation/index.rst new file mode 100644 index 0000000..646d020 --- /dev/null +++ b/documentation/installation/index.rst @@ -0,0 +1,22 @@ + +.. _Installation Manual: + +====================================== +Belden CoreOS EMMC Installation Manual +====================================== + +.. important:: + + This manual expect that the board you want to install CoreOS on have a + running UEFI firmware based on u-boot. Information about how to get console + access and a running firmware can be found for your hardware in the + :ref:`Hardware Overview ` + +| + +.. toctree:: + :caption: Table of Contents + :numbered: + + starting + partitionning \ No newline at end of file diff --git a/documentation/installation/partitionning.rst b/documentation/installation/partitionning.rst new file mode 100644 index 0000000..727b7f2 --- /dev/null +++ b/documentation/installation/partitionning.rst @@ -0,0 +1,50 @@ +************ +Installation +************ + +The installer automatically creates all the needed partitions when starting up. + +Now you have to upload the .swu file to start the flashing process. + +Choose one of these methods to upload the system image to the installer: + +Upload the .swu file over the network using a browser +===================================================== + + +Now you can install the desired CoreOS version by uploading the desired +.swu file to the board using a browser, by going to http://:8080 + +Upload the .swu file over the network using devtool +=================================================== + +If you have a working build environement, you can upload the image using +the devtool command: + +.. code-block:: + + MACHINE= devtool swupdate-www-push + + +.. hint:: + Replace with the image recipe name, eg: coreos-image-all-features + Replace by the machine name (if not set in local.conf) + Replace by the IP adress of the board + +Upload the .swu file over the network using coreos-device +========================================================= + +If you don't have a working build environement, you can upload the image using +the coreos-device python script: + +.. code-block:: + + ./coreos-device swupdate-www-push + +.. hint:: + Replace with the the path to the SWU, eg: ./coreos-image-all-features-.swu + Replace by the IP adress of the board + +.. hint:: + You will find the coreos-device script under the scripts directory inside + the CoreOS repository. diff --git a/documentation/installation/starting.rst b/documentation/installation/starting.rst new file mode 100644 index 0000000..ee9fc3d --- /dev/null +++ b/documentation/installation/starting.rst @@ -0,0 +1,64 @@ +********************** +Starting the installer +********************** + +Choose one of these methods to start the bootloader: + +Starting the installer over the network with TFTP +================================================= + +Put the coreos-installer EFI bundle (coreos-installer-.efi) into an +accessible TFTP server, then enter the following command into u-boot: + +.. code-block:: + + setenv ipaddr ; setenv serverip ; + tftp $loadaddr coreos-installer-.efi + bootefi $loadaddr + +.. hint:: + + Replace by a valid IP adress for the target, eg: 192.168.1.1 + Replace by the IP adress of the server, eg: 192.168.1.254 + Replace by the name of the machine set in bitbake + +Starting the installer over the network with DHCP/BOOTP/TFTP +============================================================ + +Use a DHCP/BOOTP/TFTP server to configure automatically the device. You can +use dnsmasq for this task. + + +.. code-block: ini + + interface= + + dhcp-range=,10.237.30.2,10.237.30.100,4h + dhcp-range=,10.237.40.2,10.237.40.100,4h + + enable-tftp + dhcp-boot=tag:,coreos-installer-.efi + tftp-root=/var/lib/tftpboot + +.. hint:: + + Replace by the name of the network interface that is connected + to the target. Eg: enp3s0 + Replace by the name of the machine set in bitbake + +Put the coreos-installer EFI bundle (coreos-installer-.efi) into the +/var/lib/tftpboot folder then enter the following command into u-boot: + +.. code-block:: + + setenv autoload yes + setenv autostart no + dhcp + bootefi $loadaddr + +Starting the installer using an SD Card +======================================= + +Flash the coreos-image-installer.wic.xz into an SDCard and put the board +in SDCard boot mode. Insert the SDCard and power up the board. The CoreOS +installer should start automatically. diff --git a/documentation/ref-manual/features.rst b/documentation/ref-manual/features.rst index 810821b..8b24be0 100644 --- a/documentation/ref-manual/features.rst +++ b/documentation/ref-manual/features.rst @@ -10,9 +10,14 @@ to Belden CoreOS. Machine Features ================ -CoreOS doesn't define any custom machine feature for now, but the :external:ref:`MACHINE_FEATURES ` of OpenEmbedded-Core -can be used. +can be used with CoreOS. + +In addition, those CoreOS specific MACHINE_FEATURES can be used too: + +- *sdcard:* the machine as an internal SD Card or MicroSD Slot. +- *emmc:* the machine as an internal emmc based storage + .. index:: DISTRO_FEATURES diff --git a/layers/meta-belden-coreos-bsp/classes/coreos-image-swupdate-beaglebone.bbclass b/layers/meta-belden-coreos-bsp/classes/coreos-image-swupdate-beaglebone.bbclass new file mode 100644 index 0000000..95141f4 --- /dev/null +++ b/layers/meta-belden-coreos-bsp/classes/coreos-image-swupdate-beaglebone.bbclass @@ -0,0 +1,26 @@ + +SWUPDATE_IMAGES += "MLO" +SWUPDATE_IMAGES += "u-boot-beaglebone" +SWUPDATE_IMAGES_FSTYPES[MLO] = "" +SWUPDATE_IMAGES_FSTYPES[u-boot-beaglebone] = ".img" + +COREOS_SWUPDATE_EXTENDS_FOR:append = "beaglebone" + +def coreos_swupdate_extends_images_for_beaglebone(d,s): + mlo = { + "filename" : "MLO", + "installed-directly" : "true", + "device" : "/dev/disk/by-partlabel/mlo", + "type" : "raw", + "sha256" : swupdate_get_sha256(d, s, "MLO"), + } + + uboot = { + "filename" : "u-boot-beaglebone.img", + "installed-directly" : "true", + "device" : "/dev/disk/by-partlabel/uboot", + "type" : "raw", + "sha256" : swupdate_get_sha256(d, s, "u-boot-beaglebone.img"), + } + + return [mlo, uboot] diff --git a/layers/meta-belden-coreos-bsp/conf/machine/beaglebone.conf b/layers/meta-belden-coreos-bsp/conf/machine/beaglebone.conf index 792d995..d5dc4b4 100644 --- a/layers/meta-belden-coreos-bsp/conf/machine/beaglebone.conf +++ b/layers/meta-belden-coreos-bsp/conf/machine/beaglebone.conf @@ -11,6 +11,7 @@ include conf/machine/include/arm/armv7a/tune-cortexa8.inc IMAGE_FSTYPES += "wic wic.xz wic.bmap" WKS_FILE ?= "beaglebone-sdcard.wks.in" +COREOS_INSTALLER_WKS_FILE ?= "beaglebone-sdcard-installer.wks" MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "kernel-image kernel-devicetree" do_image_wic[depends] += "mtools-native:do_populate_sysroot dosfstools-native:do_populate_sysroot gptfdisk-native:do_populate_sysroot virtual/bootloader:do_deploy" do_image_wic[recrdeptask] += "do_bootimg" @@ -36,9 +37,6 @@ UBOOT_LOADADDRESS = "0x80008000" MACHINE_FEATURES = "usbgadget usbhost vfat alsa" -IMAGE_BOOT_FILES ?= "u-boot.${UBOOT_SUFFIX} ${SPL_BINARY}" -IMAGE_EFI_BOOT_FILES ?= "${KERNEL_DEVICETREE}" - # support runqemu EXTRA_IMAGEDEPENDS += "qemu-native qemu-helper-native" IMAGE_CLASSES += "qemuboot" @@ -59,5 +57,7 @@ QB_TCPSERIAL_OPT = "-device virtio-serial-device -chardev socket,id=virtcon,port # No watchdog available yet EFIBOOTGUARD_TIMEOUT ?= "0" +COREOS_IMAGE_SWUPDATE_EXTRACLASSES += "coreos-image-swupdate-beaglebone" + require conf/machine/include/coreos-generic-features/efi.inc -require conf/machine/include/coreos-generic-features/emmc.inc +require conf/machine/include/coreos-generic-features/partitions.inc diff --git a/layers/meta-belden-coreos-bsp/conf/machine/include/coreos-generic-features/efi.inc b/layers/meta-belden-coreos-bsp/conf/machine/include/coreos-generic-features/efi.inc index d3b0018..44c7808 100644 --- a/layers/meta-belden-coreos-bsp/conf/machine/include/coreos-generic-features/efi.inc +++ b/layers/meta-belden-coreos-bsp/conf/machine/include/coreos-generic-features/efi.inc @@ -4,12 +4,3 @@ MACHINE_FEATURES:append = " efi" do_image_wic[depends] += "efibootguard-native:do_populate_sysroot efibootguard:do_deploy" - -# Variable used in WKS file - -WKS_PART_EFI ??= 'part --source efibootguard-efi --label efi --align 1024 --part-type=EF00' -WKS_PART_ROOT_A ??= 'part / --source rootfs --fstype=ext4 --label rootfs0 --align 1024' -WKS_PART_ROOT_B ??= 'part --fstype=ext4 --label rootfs1 --align 1024' -WKS_PART_ROOT_SIZE ??= '2G' -WKS_PART_EFIBOOTGUARD_A ??= 'part --source efibootguard-boot --label ebg0 --align 1024 --part-type=0700 --sourceparams "watchdog=${EFIBOOTGUARD_TIMEOUT},revision=2,kernel=kernel0-${MACHINE}.efi;KERNEL.EFI"' -WKS_PART_EFIBOOTGUARD_B ??= 'part --source efibootguard-boot --label ebg1 --align 1024 --part-type=0700 --sourceparams "watchdog=${EFIBOOTGUARD_TIMEOUT},revision=1,kernel=kernel1-${MACHINE}.efi;KERNEL.EFI"' diff --git a/layers/meta-belden-coreos-bsp/conf/machine/include/coreos-generic-features/emmc.inc b/layers/meta-belden-coreos-bsp/conf/machine/include/coreos-generic-features/emmc.inc deleted file mode 100644 index 87e64f5..0000000 --- a/layers/meta-belden-coreos-bsp/conf/machine/include/coreos-generic-features/emmc.inc +++ /dev/null @@ -1,7 +0,0 @@ -# This configuration file should be included for all hardware that has an -# integrated emmc - -MACHINE_FEATURES += "emmc" - -# Generate a SWU image to flash the emmc -do_image[depends] += "coreos-emmc-flasher-${MACHINE}:do_swuimage" diff --git a/layers/meta-belden-coreos-bsp/conf/machine/include/coreos-generic-features/partitions.inc b/layers/meta-belden-coreos-bsp/conf/machine/include/coreos-generic-features/partitions.inc new file mode 100644 index 0000000..e062876 --- /dev/null +++ b/layers/meta-belden-coreos-bsp/conf/machine/include/coreos-generic-features/partitions.inc @@ -0,0 +1,15 @@ + +# Variable used in WKS file + +WKS_PART_EFI ??= 'part --source efibootguard-efi --label efi --part-type=EF00' +WKS_PART_EFIBOOTGUARD_A ??= 'part --source efibootguard-boot --label ebg0 --part-type=0700 --sourceparams "watchdog=${EFIBOOTGUARD_TIMEOUT},revision=2,kernel=kernel0-${MACHINE}.efi;KERNEL.EFI"' +WKS_PART_EFIBOOTGUARD_B ??= 'part --source efibootguard-boot --label ebg1 --part-type=0700 --sourceparams "watchdog=${EFIBOOTGUARD_TIMEOUT},revision=1,kernel=kernel1-${MACHINE}.efi;KERNEL.EFI"' +WKS_PART_ROOT_A ??= 'part / --source rootfs --fstype=ext4 --label rootfs0' +WKS_PART_ROOT_B ??= 'part --fstype=ext4 --label rootfs1' +WKS_PART_ROOT_SIZE ??= '2G' + +SFDISK_PART_EFI ??= 'type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, name="efi"' +SFDISK_PART_EFIBOOTGUARD_A ??= 'type=EBD0A0A2-B9E5-4433-87C0-68B6B72699C7, name="ebg0"' +SFDISK_PART_EFIBOOTGUARD_B ??= 'type=EBD0A0A2-B9E5-4433-87C0-68B6B72699C7, name="ebg1"' +SFDISK_PART_ROOT_A ??= 'type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, name="rootfs0"' +SFDISK_PART_ROOT_B ??= 'type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, name="rootfs0"' diff --git a/layers/meta-belden-coreos-bsp/conf/machine/include/coreos-generic-machine/vm.inc b/layers/meta-belden-coreos-bsp/conf/machine/include/coreos-generic-machine/vm.inc index eef8e70..b9c3df6 100644 --- a/layers/meta-belden-coreos-bsp/conf/machine/include/coreos-generic-machine/vm.inc +++ b/layers/meta-belden-coreos-bsp/conf/machine/include/coreos-generic-machine/vm.inc @@ -22,3 +22,4 @@ do_image_wic[recrdeptask] += "do_bootimg" COREOS_EFI_SECUREBOOT_INSTALL_PUBKEY_IN_EFIDIR = "1" require conf/machine/include/coreos-generic-features/efi.inc +require conf/machine/include/coreos-generic-features/partitions.inc diff --git a/layers/meta-belden-coreos-bsp/recipes-bsp/coreos-emmc-flasher/coreos-emmc-flasher-beaglebone.bb b/layers/meta-belden-coreos-bsp/recipes-bsp/coreos-emmc-flasher/coreos-emmc-flasher-beaglebone.bb deleted file mode 100644 index f3d2678..0000000 --- a/layers/meta-belden-coreos-bsp/recipes-bsp/coreos-emmc-flasher/coreos-emmc-flasher-beaglebone.bb +++ /dev/null @@ -1,6 +0,0 @@ -COMPATIBLE_MACHINE = "beaglebone" - -require coreos-emmc-flasher.inc -require coreos-emmc-flasher-uboot.inc - -SWUPDATE_IMAGES += "MLO" diff --git a/layers/meta-belden-coreos-bsp/recipes-bsp/coreos-emmc-flasher/coreos-emmc-flasher-beaglebone/sw-description b/layers/meta-belden-coreos-bsp/recipes-bsp/coreos-emmc-flasher/coreos-emmc-flasher-beaglebone/sw-description deleted file mode 100644 index a2b6359..0000000 --- a/layers/meta-belden-coreos-bsp/recipes-bsp/coreos-emmc-flasher/coreos-emmc-flasher-beaglebone/sw-description +++ /dev/null @@ -1,48 +0,0 @@ -software = -{ - version = "@@DISTRO_VERSION@@"; - @@MACHINE@@ = { - hardware-compatibility: ["1.0"]; - factory = { - emmc = { - partitions: ( - { - type = "diskpart"; - device = "/dev/mmcblk1"; - properties: { - labeltype = "dos"; - partition-1 = [ "size=32M", "start=133120", "name=efi", "type=0xef", "fstype=fat16"]; - }; - } - ); - images: ( - { - filename = "MLO"; - device = "/dev/mmcblk1"; - offset = "128K"; - sha256 = "$swupdate_get_sha256(MLO)"; - }, - { - filename = "u-boot-beaglebone.img"; - device = "/dev/mmcblk1"; - offset = "384K"; - sha256 = "$swupdate_get_sha256(u-boot-beaglebone.img)"; - - } - ); - files: ( - { - filename = "efibootguardarm.efi"; - path = "/EFI/BOOT/bootarm.efi"; - device = "/dev/mmcblk1p1"; - filesystem = "vfat"; - sha256 = "$swupdate_get_sha256(efibootguardarm.efi)"; - properties: { - create-destination = "true"; - } - } - ); - } - } - } -} diff --git a/layers/meta-belden-coreos-bsp/recipes-bsp/coreos-emmc-flasher/coreos-emmc-flasher-uboot.inc b/layers/meta-belden-coreos-bsp/recipes-bsp/coreos-emmc-flasher/coreos-emmc-flasher-uboot.inc deleted file mode 100644 index f096e38..0000000 --- a/layers/meta-belden-coreos-bsp/recipes-bsp/coreos-emmc-flasher/coreos-emmc-flasher-uboot.inc +++ /dev/null @@ -1,10 +0,0 @@ -# Machine that use u-boot can include this file after -# coreo-swupdate-flasher.inc - -# Add support to flash u-boot -IMAGE_DEPENDS += "virtual/bootloader" - -UBOOT_SUFFIX ??= "img" -SWUPDATE_IMAGES += "u-boot" -SWUPDATE_IMAGES_FSTYPES[u-boot] = ".${UBOOT_SUFFIX}" - diff --git a/layers/meta-belden-coreos-bsp/recipes-bsp/coreos-emmc-flasher/coreos-emmc-flasher.inc b/layers/meta-belden-coreos-bsp/recipes-bsp/coreos-emmc-flasher/coreos-emmc-flasher.inc deleted file mode 100644 index fdf4049..0000000 --- a/layers/meta-belden-coreos-bsp/recipes-bsp/coreos-emmc-flasher/coreos-emmc-flasher.inc +++ /dev/null @@ -1,31 +0,0 @@ - -DESCRIPTION = "SWU Image generation to flash the internal emmc" -SECTION = "bootloaders" -LICENSE = "CLOSED" -PR = "r1" - -SRC_URI = " \ - file://sw-description \ - " - -# efibootguard -# ============================================================================== -# efibootguard support is not machine depends so it can be done here - -require conf/image-uefi.conf - -# The efibootguard binary has to be embedded into the image. swupdate will check -# that the binary exist -IMAGE_DEPENDS += "efibootguard" -SWUPDATE_IMAGES += "efibootguard${EFI_ARCH}" - -# Override or variable are not supported in var[flag] statement, but having more -# flags than necessary doesn't do any arm -SWUPDATE_IMAGES_FSTYPES[efibootguardx64] = ".efi" -SWUPDATE_IMAGES_FSTYPES[efibootguardaa64] = ".efi" -SWUPDATE_IMAGES_FSTYPES[efibootguardarm] = ".efi" - -# Image generated should be named coreos-swupdater-flasher-${MACHINE} -# and not the default coreos-swupdate-flasher-${MACHINE}-${MACHINE} -IMAGE_BASENAME ?= "coreos-emmc-flasher" -inherit swupdate diff --git a/layers/meta-belden-coreos-bsp/recipes-coreos/coreos-installer/coreos-installer-config/beaglebone_1.0.sfdisk b/layers/meta-belden-coreos-bsp/recipes-coreos/coreos-installer/coreos-installer-config/beaglebone_1.0.sfdisk new file mode 100644 index 0000000..3cc9887 --- /dev/null +++ b/layers/meta-belden-coreos-bsp/recipes-coreos/coreos-installer/coreos-installer-config/beaglebone_1.0.sfdisk @@ -0,0 +1,19 @@ +label: gpt +device: /dev/mmcblk1 +unit: sectors +first-lba: 34 +last-lba: 7471070 +sector-size: 512 + +# EBBR 2.1.0 section 4.1.1 mandate the use of an unused type UUID and to set +# the RequiredPartition label for part of the firmware stored in the main disk +# https://arm-software.github.io/ebbr/#section-gpt-parts +# next two type were generated +/dev/mmcblk1p1 : start= 256, size= 512, type=4DA6E9DA-C803-4BE4-BAC4-8192717C5EB0, name="mlo", attrs="RequiredPartition" +/dev/mmcblk1p2 : start= 768, size= 8192, type=5B97345D-B7A1-47D3-A491-ED40F4841639, name="uboot", attrs="RequiredPartition" + +/dev/mmcblk1p3 : start= 8960, size= 131072, ${SFDISK_PART_EFI} +/dev/mmcblk1p4 : start= 140032, size= 262144, ${SFDISK_PART_EFIBOOTGUARD_A} +/dev/mmcblk1p5 : start= 402176, size= 262144, ${SFDISK_PART_EFIBOOTGUARD_B} +/dev/mmcblk1p6 : start= 664320, size= 3403375, ${SFDISK_PART_ROOT_A} +/dev/mmcblk1p7 : start= 4067695, size= 3403375, ${SFDISK_PART_ROOT_B} diff --git a/layers/meta-belden-coreos-bsp/recipes-coreos/coreos-installer/coreos-installer-config_%.bbappend b/layers/meta-belden-coreos-bsp/recipes-coreos/coreos-installer/coreos-installer-config_%.bbappend new file mode 100644 index 0000000..749c84f --- /dev/null +++ b/layers/meta-belden-coreos-bsp/recipes-coreos/coreos-installer/coreos-installer-config_%.bbappend @@ -0,0 +1,3 @@ +FILESEXTRAPATHS:prepend := "${THISDIR}/coreos-installer-config:" + +SRC_URI:append:beaglebone = " file://beaglebone_1.0.sfdisk" diff --git a/layers/meta-belden-coreos-bsp/wic/beaglebone-sdcard-installer.wks b/layers/meta-belden-coreos-bsp/wic/beaglebone-sdcard-installer.wks new file mode 100644 index 0000000..eed45a4 --- /dev/null +++ b/layers/meta-belden-coreos-bsp/wic/beaglebone-sdcard-installer.wks @@ -0,0 +1,20 @@ +# short-description: Create SD card image for Beaglebone +# long-description: Creates a partitioned SD card image for Beaglebone. + +# offset 1S => 1 sector (1x512 byte) +# The bootloader can be at 4 different position in raw mode: 0S, 256S, 512S, 768S +# MBR disk use only the sector 0, so 1S is free +# GPT disk use sector 0-33S, so first free slot is 256S +# Offset are from the BBB default settings + +# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +# Don't name partition in the installer disk image, otherwise the installer may not work as it rely on partition label! +# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +part --offset 256S --source rawcopy --sourceparams="file=MLO" --ondisk mmcblk0 --fixed-size 256K +part --offset 768S --source rawcopy --sourceparams="file=u-boot.img" --ondisk mmcblk0 --fixed-size 4M + +# Let's define a 4MiB maximum size for the bootloader +# 4MiB => 4*1024*1024/512=8192S | 768S + 8192S => 8960S +part --source bootimg-partition --part-type=EF00 --ondisk mmcblk0 --offset 8960S --fixed-size 125M +bootloader --ptable gpt diff --git a/layers/meta-belden-coreos-bsp/wic/beaglebone-sdcard.wks.in b/layers/meta-belden-coreos-bsp/wic/beaglebone-sdcard.wks.in index 714169d..cfaac14 100644 --- a/layers/meta-belden-coreos-bsp/wic/beaglebone-sdcard.wks.in +++ b/layers/meta-belden-coreos-bsp/wic/beaglebone-sdcard.wks.in @@ -6,15 +6,15 @@ # MBR disk use only the sector 0, so 1S is free # GPT disk use sector 0-33S, so first free slot is 256S # Offset are from the BBB default settings -part --offset 256S --source rawcopy --sourceparams="file=MLO" --ondisk mmcblk0 -part --offset 768S --source rawcopy --sourceparams="file=u-boot.img" --ondisk mmcblk0 +part --offset 256S --source rawcopy --sourceparams="file=MLO" --ondisk mmcblk0 --fixed-size 256K --part-name "mlo" +part --offset 768S --source rawcopy --sourceparams="file=u-boot.img" --ondisk mmcblk0 --fixed-size 4M --part-name "uboot" # Let's define a 4MiB maximum size for the bootloader # 4MiB => 4*1024*1024/512=8192S | 768S + 8192S => 8960S -${WKS_PART_EFI} --ondisk mmcblk0 --offset 8960S --align 1024 --size 32M --extra-space 0 --overhead-factor 1 -${WKS_PART_ROOT_A} --ondisk mmcblk0 --size ${WKS_PART_ROOT_SIZE} --extra-space 0 --overhead-factor 1 -${WKS_PART_ROOT_B} --ondisk mmcblk0 --size ${WKS_PART_ROOT_SIZE} --extra-space 0 --overhead-factor 1 -${WKS_PART_EFIBOOTGUARD_A} --ondisk mmcblk0 --align 1024 --size 128M --extra-space 0 --overhead-factor 1 -${WKS_PART_EFIBOOTGUARD_B} --ondisk mmcblk0 --align 1024 --size 128M --extra-space 0 --overhead-factor 1 +${WKS_PART_EFI} --ondisk mmcblk0 --offset 8960S --fixed-size 32M +${WKS_PART_EFIBOOTGUARD_A} --ondisk mmcblk0 --fixed-size 128M +${WKS_PART_EFIBOOTGUARD_B} --ondisk mmcblk0 --fixed-size 128M +${WKS_PART_ROOT_A} --ondisk mmcblk0 --fixed-size ${WKS_PART_ROOT_SIZE} +${WKS_PART_ROOT_B} --ondisk mmcblk0 --fixed-size ${WKS_PART_ROOT_SIZE} bootloader --ptable gpt diff --git a/layers/meta-belden-coreos/classes/coreos-image-ci.bbclass b/layers/meta-belden-coreos/classes/coreos-image-ci.bbclass index 0d30147..7e073e8 100644 --- a/layers/meta-belden-coreos/classes/coreos-image-ci.bbclass +++ b/layers/meta-belden-coreos/classes/coreos-image-ci.bbclass @@ -32,6 +32,12 @@ def get_coreos_ci_artifacts(d): if d.getVar('COREOS_IMAGE_GENERATE_SWU') == '1': artifacts.append(d.getVar('IMAGE_LINK_NAME') + '.swu') + # CoreOS Installer + # ========================================================================== + + if d.getVar('COREOS_IMAGE_GENERATE_INSTALLER') == '1': + artifacts.append('coreos-installer-' + d.getVar('MACHINE') + '.efi') + # Kernel # ========================================================================== diff --git a/layers/meta-belden-coreos/classes/coreos-image-uki.bbclass b/layers/meta-belden-coreos/classes/coreos-image-uki.bbclass index 5a7baea..59646d4 100644 --- a/layers/meta-belden-coreos/classes/coreos-image-uki.bbclass +++ b/layers/meta-belden-coreos/classes/coreos-image-uki.bbclass @@ -20,22 +20,21 @@ COREOS_KERNEL1 ??= "${DEPLOY_DIR_IMAGE}/${COREOS_KERNEL1_FILENAME}" # Kernel command line # ============================================================================== -APPEND += "rootwait " COREOS_ROOTFS0_ROOT ??= "PARTLABEL=rootfs0" COREOS_ROOTFS1_ROOT ??= "PARTLABEL=rootfs1" -COREOS_KERNEL0_CMDLINE ??= "root=${COREOS_ROOTFS0_ROOT} ${APPEND}" -COREOS_KERNEL1_CMDLINE ??= "root=${COREOS_ROOTFS1_ROOT} ${APPEND}" +COREOS_KERNEL0_CMDLINE ??= "root=${COREOS_ROOTFS0_ROOT} ${APPEND} rootwait" +COREOS_KERNEL1_CMDLINE ??= "root=${COREOS_ROOTFS1_ROOT} ${APPEND} rootwait" COREOS_UKI_PART_KERNEL_FILENAME ??= "${KERNEL_IMAGETYPE}-${MACHINE}${KERNEL_IMAGE_BIN_EXT}" COREOS_UKI_PART_KERNEL ??= "${DEPLOY_DIR_IMAGE}/${COREOS_UKI_PART_KERNEL_FILENAME}" COREOS_UKI_PART_STUB_FILENAME ??= "kernel-stub${EFI_ARCH}.efi" COREOS_UKI_PART_STUB ??= "${STAGING_LIBDIR}/efibootguard/${COREOS_UKI_PART_STUB_FILENAME}" - +COREOS_UKI_PART_INITRAMFS ??= "" # UKI Generation # ============================================================================== -do_bundle_uki() { +do_image_uki() { deployDir="${DEPLOY_DIR_IMAGE}" # Create an array with device tree if any @@ -51,6 +50,13 @@ do_bundle_uki() { echo "dtb: ${DTB_PARAMS}" echo "cmdline0: ${COREOS_KERNEL0_CMDLINE}" echo "cmdline1: ${COREOS_KERNEL1_CMDLINE}" + echo "initramfs: ${COREOS_UKI_PART_INITRAMFS}" + + if [ ! -z "${COREOS_UKI_PART_INITRAMFS}" ]; then + DTB_PARAMS="${DTB_PARAMS} --initrd=${COREOS_UKI_PART_INITRAMFS}" + fi + + echo "initramfs: ${INITRAMFS_PARAMS}" bg_gen_unified_kernel \ "${COREOS_UKI_PART_STUB}" \ @@ -70,5 +76,16 @@ do_bundle_uki() { coreos_efi_secureboot_sign_app "${deployDir}/${COREOS_KERNEL1_FILENAME}" } -do_bundle_uki[depends] += "virtual/kernel:do_deploy efibootguard-native:do_populate_sysroot efibootguard:do_populate_sysroot" -addtask bundle_uki after do_rootfs before do_image +do_image_uki[depends] += "virtual/kernel:do_deploy efibootguard-native:do_populate_sysroot efibootguard:do_populate_sysroot" + + +addtask image_uki after do_image before do_image_complete + +# UKI image is normally embedded into a WIC image +do_image_wic[recrdeptask] += "do_image_uki" + +# UKI image is normally embedded into a SWU image +do_image_swu[recrdeptask] += "${@'do_image_uki' if d.getVar('COREOS_IMAGE_GENERATE_SWU') == '1' else ''}" + +# UKI image may embedded the rootfs as a cpio archive, in this case do_image_uki should run after do_image_cpio +do_image_uki[recrdeptask] += "${@'do_image_cpio' if d.getVar('COREOS_UKI_PART_INITRAMFS') else ''}" diff --git a/layers/meta-belden-coreos/classes/coreos-image.bbclass b/layers/meta-belden-coreos/classes/coreos-image.bbclass index 18ff680..057d652 100644 --- a/layers/meta-belden-coreos/classes/coreos-image.bbclass +++ b/layers/meta-belden-coreos/classes/coreos-image.bbclass @@ -90,9 +90,13 @@ IMAGE_ROOTFS_EXTRA_SPACE:append = " ${@bb.utils.contains('DISTRO_FEATURES', 'sys # ============================================================================== # Support for Unified Kernel Image and Swupdate are optional +COREOS_IMAGE_GENERATE_INSTALLER ?= "1" COREOS_IMAGE_GENERATE_UKI ?= "1" COREOS_IMAGE_GENERATE_SWU ?= "1" +# Generate the installer image if needed +do_build[depends] += "${@'coreos-image-installer:do_build' if d.getVar('COREOS_IMAGE_GENERATE_INSTALLER') == '1' else ''}" + COREOS_IMAGE_EXTRACLASSES += "${@'coreos-image-uki' if d.getVar('COREOS_IMAGE_GENERATE_UKI') == '1' else ''}" COREOS_IMAGE_EXTRACLASSES += "${@'coreos-image-swupdate' if d.getVar('COREOS_IMAGE_GENERATE_SWU') == '1' else ''}" diff --git a/layers/meta-belden-coreos/conf/distro/belden-coreos.conf b/layers/meta-belden-coreos/conf/distro/belden-coreos.conf index 11944d3..8b22836 100644 --- a/layers/meta-belden-coreos/conf/distro/belden-coreos.conf +++ b/layers/meta-belden-coreos/conf/distro/belden-coreos.conf @@ -78,3 +78,10 @@ INHERIT += "coreos-efi-secureboot" #PREFERRED_PROVIDER_virtual/runc = "crun" PACKAGECONFIG:append:pn-podman = " rootless" DISTRO_FEATURES_DEFAULT += "virtualization seccomp ipv6" + +# CoreOS specific options +# ============================================================================== + +# Distro based on CoreOS can provide their own configuration files for the +# CoreOS installer by overriding this variable +PREFERRED_PROVIDER_coreos-installer-config ??= "coreos-installer-config" diff --git a/layers/meta-belden-coreos/recipes-core/images/coreos-image-installer.bb b/layers/meta-belden-coreos/recipes-core/images/coreos-image-installer.bb new file mode 100644 index 0000000..f5c4b5c --- /dev/null +++ b/layers/meta-belden-coreos/recipes-core/images/coreos-image-installer.bb @@ -0,0 +1,53 @@ +DESCRIPTION = "Initramfs image with the CoreOS emmc installer" + + + +# Don't reboot the device at reboot and don't do A/B switching +BAD_RECOMMENDATIONS = "swupdate-progress swupdate-coreos-config" + +export IMAGE_BASENAME = "${MLPREFIX}${PN}" +IMAGE_NAME_SUFFIX ?= "" +IMAGE_LINGUAS = "" + +LICENSE = "MIT" + +IMAGE_FSTYPES = "cpio.gz" + +# Support for generating a SDCard installer is optional +COREOS_INSTALLER_WKS_FILE ??= "" +WKS_FILE = "${COREOS_INSTALLER_WKS_FILE}" +IMAGE_FSTYPES += "${@'wic.xz wic.bmap' if d.getVar('COREOS_INSTALLER_WKS_FILE') else ''}" +IMAGE_BOOT_FILES = "${COREOS_KERNEL0_FILENAME};EFI/BOOT/${EFI_BOOT_IMAGE}" + +COREOS_IMAGE_GENERATE_UKI = "1" + +# Avoid dependancy loop, we are already in an installer image, so we don't need +# to bundle another one +COREOS_IMAGE_GENERATE_INSTALLER = "0" + +# IMGDEPLOYDIR has to be used instead of DEPLOY_DIR_IMAGE here, because it will +# run during image generation +COREOS_UKI_PART_INITRAMFS = "${IMGDEPLOYDIR}/${IMAGE_BASENAME}-${MACHINE}.cpio.gz" +COREOS_IMAGE_GENERATE_SWU = "0" + +# Change generated UKI filename and bundled command line +# Having the same name to KERNEL0 and KERNEL1 means that KERNEL1 will overwrite +# KERNEL0. +COREOS_KERNEL0_NAME ?= "coreos-installer-${MACHINE}" +COREOS_KERNEL1_NAME ?= "coreos-installer-${MACHINE}" +COREOS_KERNEL0_CMDLINE ?= "${APPEND}" +COREOS_KERNEL1_CMDLINE ?= "${APPEND}" + +inherit coreos-image + +# Only install a reduced set of package and feature to keep image size small +IMAGE_INSTALL = "packagegroup-coreos-boot coreos-installer swupdate-www util-linux-sfdisk util-linux-fdisk util-linux-cfdisk efibootguard efibootguard-tools" +IMAGE_FEATURES = "debug-tweaks swupdate networkmanager" +NO_RECOMMENDATIONS = "1" + +IMAGE_ROOTFS_SIZE = "8192" +INITRAMFS_MAXSIZE = "976562" +IMAGE_ROOTFS_EXTRA_SPACE = "0" + +# Use the same restriction as initramfs-module-install +COMPATIBLE_HOST = '(x86_64.*|i.86.*|arm.*|aarch64.*)-(linux.*|freebsd.*)' diff --git a/layers/meta-belden-coreos/recipes-core/packagegroups/packagegroup-coreos-swupdate.bb b/layers/meta-belden-coreos/recipes-core/packagegroups/packagegroup-coreos-swupdate.bb index d8429c4..1a8d1a7 100644 --- a/layers/meta-belden-coreos/recipes-core/packagegroups/packagegroup-coreos-swupdate.bb +++ b/layers/meta-belden-coreos/recipes-core/packagegroups/packagegroup-coreos-swupdate.bb @@ -3,14 +3,15 @@ DESCRIPTION = "Install swupdate and related components" inherit packagegroup - PACKAGES = "\ ${PN} \ " RDEPENDS:${PN} = "\ swupdate \ - swupdate-progress \ swupdate-client \ swupdate-lua \ " + +# swupdate-progress will reboot the device at the end of the update +RRECOMMENDS:${PN} = "swupdate-progress" diff --git a/layers/meta-belden-coreos/recipes-coreos/coreos-installer/coreos-installer-config.inc b/layers/meta-belden-coreos/recipes-coreos/coreos-installer/coreos-installer-config.inc new file mode 100644 index 0000000..52e06e0 --- /dev/null +++ b/layers/meta-belden-coreos/recipes-coreos/coreos-installer/coreos-installer-config.inc @@ -0,0 +1,49 @@ +DESCRIPTION = "CoreOS Installer configuration files" +SECTION = "coreos" +LICENSE = "CLOSED" + +# This file can be included by a CoreOS based distro to ship a customized +# version +RPROVIDES:${PN} += "coreos-installer-config" +PROVIDES += "coreos-installer-config" + +# This package is intended to ship machine specific configuration file +# See bbappend in BSP layers +PACKAGE_ARCH = "${MACHINE_ARCH}" + +# If the BSP doesn't provide a machine specific configuration file, this +# package will be empty +ALLOW_EMPTY:${PN} = "1" + +# Don't run default configure and compile task +do_configure[noexex] = "1" + +python do_compile() { + from pathlib import Path + + workdir = Path(d.getVar('WORKDIR', True)) + machine = d.getVar('MACHINE', True) + b = Path(d.getVar('B', True)) + for input_path in workdir.glob(f'{machine}_*.sfdisk'): + output_path = b / input_path.relative_to(workdir) + process_sfdisk_file(d, input_path, output_path) + +} + +def process_sfdisk_file(d, input_path, output_path): + """ + Read the file from input_path and write it to output_path with bitbake + variable expanded + """ + with open(output_path, "w") as output_file: + with open(input_path, "r") as input_file: + for line in input_file.readlines(): + output_file.write(d.expand(line)) + +do_install() { + install -d ${D}${sysconfdir} + + # Install all files for the current machine but don't fail if no file is + # found + install -m 755 ${B}/${MACHINE}_*.sfdisk ${D}${sysconfdir}/ || true +} diff --git a/layers/meta-belden-coreos/recipes-coreos/coreos-installer/coreos-installer-config_1.0.bb b/layers/meta-belden-coreos/recipes-coreos/coreos-installer/coreos-installer-config_1.0.bb new file mode 100644 index 0000000..73c3c5b --- /dev/null +++ b/layers/meta-belden-coreos/recipes-coreos/coreos-installer/coreos-installer-config_1.0.bb @@ -0,0 +1,3 @@ +# Code is in an include file as they can be reused by a CoreOS distro to ship +# an alternative provided for coreos-installer-config using PREFERRED_PROVIDER +require coreos-installer-config.inc diff --git a/layers/meta-belden-coreos/recipes-coreos/coreos-installer/coreos-installer/25-installer-config.sh b/layers/meta-belden-coreos/recipes-coreos/coreos-installer/coreos-installer/25-installer-config.sh new file mode 100644 index 0000000..9a919f3 --- /dev/null +++ b/layers/meta-belden-coreos/recipes-coreos/coreos-installer/coreos-installer/25-installer-config.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env sh + +# Read /etc/hwrevision and turn it into a stripped string +# with the format ${MACHINE}_${VERSION} +HWREVISION=$(tr ' ' '_' < /etc/hwrevision | tr -d '[:space:]') + +# Format the disk +SFDISK_DUMP_FILE="/etc/${HWREVISION}.sfdisk" + +if [ ! -f "${SFDISK_DUMP_FILE}" ] +then + echo "Configuration file ${SFDISK_DUMP_FILE} not found" + exit 1 +fi + +DISK=$(grep "^device:\s" < "${SFDISK_DUMP_FILE}" | cut -d ' ' -f 2) + +echo "Flashing ${SFDISK_DUMP_FILE} to ${DISK}" +cat "${SFDISK_DUMP_FILE}" +sfdisk "${DISK}" < "${SFDISK_DUMP_FILE}" + +# Give the kernel some time to reload the partition +sleep 3 + +# Create EFI and EFIBootGuard partition as FAT16 +mkfs.fat -F 16 -n EFI /dev/disk/by-partlabel/efi +mkfs.fat -F 16 -n EBG0 /dev/disk/by-partlabel/ebg0 +mkfs.fat -F 16 -n EBG1 /dev/disk/by-partlabel/ebg1 + +mkdir -p /mnt/ebg0 +mkdir -p /mnt/ebg1 +mkdir -p /mnt/efi + +mount /dev/disk/by-partlabel/ebg0 /mnt/ebg0 +mount /dev/disk/by-partlabel/ebg1 /mnt/ebg1 +mount /dev/disk/by-partlabel/efi /mnt/efi + +mkdir -p /mnt/efi/EFI/BOOT + +echo -n "EBG0" | iconv -f ascii -t UTF-16LE > /mnt/ebg0/EFILABEL +bg_setenv -f /mnt/ebg0/BGENV.DAT -r 0 -s FAILED + +echo -n "EBG1" | iconv -f ascii -t UTF-16LE > /mnt/ebg1/EFILABEL +bg_setenv -f /mnt/ebg1/BGENV.DAT -r 0 -s FAILED + +umount /mnt/ebg0 +umount /mnt/ebg1 +umount /mnt/efi + +SWUPDATE_ARGS="${SWUPDATE_ARGS} -e stable,copy0" diff --git a/layers/meta-belden-coreos/recipes-coreos/coreos-installer/coreos-installer_1.0.bb b/layers/meta-belden-coreos/recipes-coreos/coreos-installer/coreos-installer_1.0.bb new file mode 100644 index 0000000..43e5bab --- /dev/null +++ b/layers/meta-belden-coreos/recipes-coreos/coreos-installer/coreos-installer_1.0.bb @@ -0,0 +1,24 @@ +DESCRIPTION = "CoreOS Installer scripts" +LICENSE = "CLOSED" +SECTION = "coreos" + +SRC_URI+= " \ + file://25-installer-config.sh \ +" + +# This package ship an alternate configuration for SWUpade to disable A/B +# switching and always flash A +RCONFLICTS:${PN}= "swupdate-coreos-config" + +FILES:${PN} = " \ + ${libdir}/swupdate/conf.d/25-installer-config.sh \ +" + +# glibc-utils provide iconv +# glibc-gconv-utf-16 provide utf-16 support to iconv +RDEPENDS:${PN} = "coreos-installer-config dosfstools util-linux-lsblk util-linux-sfdisk glibc-utils glibc-gconv-utf-16" + +do_install() { + install -d ${D}${libdir}/swupdate/conf.d + install -m 755 ${WORKDIR}/25-installer-config.sh ${D}${libdir}/swupdate/conf.d/ +} diff --git a/layers/meta-belden-coreos/recipes-support/swupdate/swupdate/0001-fs-add-support-to-create-FAT16-partition.patch b/layers/meta-belden-coreos/recipes-support/swupdate/swupdate/0001-fs-add-support-to-create-FAT16-partition.patch deleted file mode 100644 index 8ee78f1..0000000 --- a/layers/meta-belden-coreos/recipes-support/swupdate/swupdate/0001-fs-add-support-to-create-FAT16-partition.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 323c7fdda60758506dea9da6c477e42a0dbe86ca Mon Sep 17 00:00:00 2001 -From: Samuel Dolt -Date: Wed, 22 Feb 2023 13:22:27 +0100 -Subject: [PATCH] fs: add support to create FAT16 partition - -Currently swupdate can create vfat partition using an embedded -copy of the fat_fs library. The partition created by fat_fs is -can be any FAT format (12/16/32) based on the partition size. - -As the partition created by fat_fs was not readable by U-Boot, -this commit add a new "fat16" filesystem type that use the -external binary mkfs.fat to always create FAT16 partition. ---- - fs/diskformat.c | 16 ++++++++++++++++ - 1 file changed, 16 insertions(+) - -diff --git a/fs/diskformat.c b/fs/diskformat.c -index 8d58fc3..f98c9d7 100644 ---- a/fs/diskformat.c -+++ b/fs/diskformat.c -@@ -19,6 +19,21 @@ static inline int ext_mkfs_short(const char *device_name, const char *fstype) - } - #endif - -+int fat_mkfs_extern(const char *device_name, const char *fstype) -+{ -+ char cmd[100] = "mkfs.fat -F "; -+ if(strcmp(fstype, "fat16") == 0){ -+ strcat(cmd, "16 "); -+ } else { -+ ERROR("fat_mkfs_extern: unsupported fstype %s", fstype); -+ return -1; -+ } -+ strncat(cmd, device_name, sizeof(cmd) - strlen(cmd) - 1); -+ -+ TRACE("fat_mkfs_extern: running %s", cmd); -+ return system(cmd); -+} -+ - struct supported_filesystems { - const char *fstype; - int (*mkfs)(const char *device_name, const char *fstype); -@@ -28,6 +43,7 @@ static struct supported_filesystems fs[] = { - #if defined(CONFIG_FAT_FILESYSTEM) - {"vfat", fat_mkfs}, - #endif -+ {"fat16", fat_mkfs_extern}, - #if defined(CONFIG_EXT_FILESYSTEM) - {"ext2", ext_mkfs_short}, - {"ext3", ext_mkfs_short}, diff --git a/layers/meta-belden-coreos/recipes-support/swupdate/swupdate/sw-collections-config.sh b/layers/meta-belden-coreos/recipes-support/swupdate/swupdate/25-sw-collections-config.sh similarity index 100% rename from layers/meta-belden-coreos/recipes-support/swupdate/swupdate/sw-collections-config.sh rename to layers/meta-belden-coreos/recipes-support/swupdate/swupdate/25-sw-collections-config.sh diff --git a/layers/meta-belden-coreos/recipes-support/swupdate/swupdate/webserver-config.sh b/layers/meta-belden-coreos/recipes-support/swupdate/swupdate/50-webserver-config.sh similarity index 100% rename from layers/meta-belden-coreos/recipes-support/swupdate/swupdate/webserver-config.sh rename to layers/meta-belden-coreos/recipes-support/swupdate/swupdate/50-webserver-config.sh diff --git a/layers/meta-belden-coreos/recipes-support/swupdate/swupdate_%.bbappend b/layers/meta-belden-coreos/recipes-support/swupdate/swupdate_%.bbappend index 88adf3d..96bea30 100644 --- a/layers/meta-belden-coreos/recipes-support/swupdate/swupdate_%.bbappend +++ b/layers/meta-belden-coreos/recipes-support/swupdate/swupdate_%.bbappend @@ -1,36 +1,43 @@ # File in the swupdate subdirectory of this recipe should overwrite the # same file in meta-swupdate FILESEXTRAPATHS:prepend := "${THISDIR}/swupdate:" -RDEPENDS:${PN}:append = " efibootguard" -SRC_URI += "file://webserver-config.sh \ - file://sw-collections-config.sh \ - file://0001-fs-add-support-to-create-FAT16-partition.patch \ - " +SRC_URI += "\ + file://50-webserver-config.sh \ + file://25-sw-collections-config.sh \ +" + +PACKAGES =+ "${PN}-coreos-config ${PN}-coreos-installer-config" -# 0001-fs-add-support-to-create-FAT16-partition.patch depends on the -# mkfs.fat binary -RDEPENDS:${PN} += "dosfstools" # Don't use /www as the web root -wwwdir = "/usr/share/swupdate-www" +wwwdir = "${datadir}/swupdate-www" -FILES:${PN} += " \ - ${SWUPDATE_SW_VERSIONS_FILE} \ - ${SWUPDATE_HW_COMPATIBILITY_FILE} \ - ${libdir}/swupdate/conf.d/sw-collections-config.sh \ -" +# Add the hwrevision files to the main package to prevent +# installation of .swu image built for another machine +FILES:${PN} += "${sysconfdir}/hwrevision" -FILES:${PN}-www += " \ - ${libdir}/swupdate/conf.d/webserver-config.sh \ -" +# If we install the webserver package, it should be started automatically +FILES:${PN}-www += "${libdir}/swupdate/conf.d/50-webserver-config.sh" + +FILES:${PN}-coreos-config += "${libdir}/swupdate/conf.d/25-sw-collections-config.sh" + +RDEPENDS:${PN}:append = " efibootguard" + +# lsblk is used in sw-collections-config.sh +RDEPENDS:${PN}-coreos-config += "util-linux-lsblk" + +# Recommends by default the configuration used for normal image +# that contain the A/B update path switch +RRECOMMENDS:${PN} += "${PN}-coreos-config" + +# The installer configuration should prevent the normal A/B switch +# configuration to be installed +RCONFLICTS:${PN}-coreos-installer-config = "${PN}-coreos-config" do_install:append() { # Probably replace revision with the value of the device tree - install -m 755 ${WORKDIR}/webserver-config.sh ${D}${libdir}/swupdate/conf.d/ - - install -m 755 ${WORKDIR}/sw-collections-config.sh ${D}${libdir}/swupdate/conf.d/ - echo "${MACHINE} 1.0" > ${D}${SWUPDATE_HW_COMPATIBILITY_FILE} + install -m 755 ${WORKDIR}/50-webserver-config.sh ${D}${libdir}/swupdate/conf.d/ + install -m 755 ${WORKDIR}/25-sw-collections-config.sh ${D}${libdir}/swupdate/conf.d/ + echo "${MACHINE} 1.0" > ${D}${sysconfdir}/hwrevision } - -PR = "r2" \ No newline at end of file diff --git a/layers/meta-belden-marvell-bsp/conf/machine/include/cn913x.inc b/layers/meta-belden-marvell-bsp/conf/machine/include/cn913x.inc index 43d3903..cf7affe 100644 --- a/layers/meta-belden-marvell-bsp/conf/machine/include/cn913x.inc +++ b/layers/meta-belden-marvell-bsp/conf/machine/include/cn913x.inc @@ -51,6 +51,7 @@ APPEND += "console=ttyS0,115200" # for a wic image do_image_wic[depends] += "trusted-firmware-a:do_deploy" WKS_FILE = "cn913x-sdcard.wks.in" +COREOS_INSTALLER_WKS_FILE ?= "cn913x-sdcard-installer.wks" IMAGE_FSTYPES += "wic.xz wic.bmap" MACHINE_ESSENTIAL_EXTRA_RDEPENDS += " kernel-modules kernel-devicetree" @@ -59,3 +60,4 @@ COREOS_IMAGE_SWUPDATE_EXTRACLASSES += " coreos-image-swupdate-cn913x" # No watchdog available yet EFIBOOTGUARD_TIMEOUT ?= "0" require conf/machine/include/coreos-generic-features/efi.inc +require conf/machine/include/coreos-generic-features/partitions.inc diff --git a/layers/meta-belden-marvell-bsp/recipes-coreos/coreos-installer/coreos-installer-config/cn9130-cf-pro_1.0.sfdisk b/layers/meta-belden-marvell-bsp/recipes-coreos/coreos-installer/coreos-installer-config/cn9130-cf-pro_1.0.sfdisk new file mode 100644 index 0000000..dfdbc02 --- /dev/null +++ b/layers/meta-belden-marvell-bsp/recipes-coreos/coreos-installer/coreos-installer-config/cn9130-cf-pro_1.0.sfdisk @@ -0,0 +1,25 @@ +label: gpt +device: /dev/mmcblk0 +unit: sectors +first-lba: 34 +last-lba: 15269854 +sector-size: 512 + +# Partition should be aligned at 2048S for best performance + +# EBBR 2.1.0 section 4.1.1 mandate the use of an unused type UUID and to set +# the RequiredPartition label for part of the firmware stored in the main disk +# https://arm-software.github.io/ebbr/#section-gpt-parts +# UUID type of fw0 and fw1 was generated +# The bootloader can be at 5 different position: 1S, 34S, 4096S, 8192S, 12288S +# GPT disk use sector 0-33S, so first free slot is 34S +# Current bootloader is about 1.8MB, so if we put it at 4096S and 12288S we +# have 4MiB between the first bootloader and the second copy of it +/dev/mmcblk0p1 : start= 4096, size= 8192, type=71B02716-C000-4F0D-AE03-2F5DC0A114CD, name="fw0", attrs="RequiredPartition" +/dev/mmcblk0p2 : start= 12288, size= 8192, type=71B02716-C000-4F0D-AE03-2F5DC0A114CD, name="fw1", attrs="RequiredPartition" + +/dev/mmcblk0p3 : start= 20480, size= 131072, ${SFDISK_PART_EFI} +/dev/mmcblk0p4 : start= 151552, size= 262144, ${SFDISK_PART_EFIBOOTGUARD_A} +/dev/mmcblk0p5 : start= 413696, size= 262144, ${SFDISK_PART_EFIBOOTGUARD_B} +/dev/mmcblk0p6 : start= 675840, size= 7294976, ${SFDISK_PART_ROOT_A} +/dev/mmcblk0p7 : start= 7970816, size= 7294976, ${SFDISK_PART_ROOT_B} diff --git a/layers/meta-belden-marvell-bsp/recipes-coreos/coreos-installer/coreos-installer-config_%.bbappend b/layers/meta-belden-marvell-bsp/recipes-coreos/coreos-installer/coreos-installer-config_%.bbappend new file mode 100644 index 0000000..3e662bc --- /dev/null +++ b/layers/meta-belden-marvell-bsp/recipes-coreos/coreos-installer/coreos-installer-config_%.bbappend @@ -0,0 +1,3 @@ +FILESEXTRAPATHS:prepend := "${THISDIR}/coreos-installer-config:" + +SRC_URI:append:cn913x = " file://cn9130-cf-pro_1.0.sfdisk" diff --git a/layers/meta-belden-marvell-bsp/wic/cn913x-sdcard-installer.wks b/layers/meta-belden-marvell-bsp/wic/cn913x-sdcard-installer.wks new file mode 100644 index 0000000..6fc5878 --- /dev/null +++ b/layers/meta-belden-marvell-bsp/wic/cn913x-sdcard-installer.wks @@ -0,0 +1,18 @@ +# short-description: Create SDCard installer image +# long-description: Create SDCard installer image + +# offset 1S => 1 sector (1x512 byte) +# The bootloader can be at 5 different position: 1S, 34S, 4096S, 8192S, 12288S +# MBR disk use only the sector 0, so 1S is free +# GPT disk use sector 0-33S, so first free slot is 34S + +# Current bootloader is about 1.8MB, so if we put it at 4096S and 12288S we +# have 4MiB between the first bootloader and the second copy of it + +# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +# Don't name partition in the installer disk image, otherwise the installer may not work as it rely on partition label! +# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +part --offset 4096S --source rawcopy --sourceparams="file=flash-image.bin" --ondisk mmcblk1 --fixed-size 4M +part --offset 12288S --source rawcopy --sourceparams="file=flash-image.bin" --ondisk mmcblk1 --fixed-size 4M +part --source bootimg-partition --part-type=EF00 --ondisk mmcblk1 --offset 20480S --fixed-size 125M +bootloader --ptable gpt