From patchwork Thu May 25 09:51:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Maly X-Patchwork-Id: 1786023 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::43b; helo=mail-wr1-x43b.google.com; envelope-from=swupdate+bncbdi33txizecrbnw7xsrqmgqenatkbni@googlegroups.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20221208 header.b=AjRoNLum; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=Sr7PeCkr; dkim-atps=neutral Received: from mail-wr1-x43b.google.com (mail-wr1-x43b.google.com [IPv6:2a00:1450:4864:20::43b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QRjy55hgpz20QL for ; Thu, 25 May 2023 19:51:56 +1000 (AEST) Received: by mail-wr1-x43b.google.com with SMTP id ffacd0b85a97d-30aa5fb26b3sf1269901f8f.0 for ; Thu, 25 May 2023 02:51:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1685008311; cv=pass; d=google.com; s=arc-20160816; b=I/wdZ7wxBTHJ6IIFFWHwc5v9jRbKN0TwJ99rv5RxmsJ6eqyztoWT/ojKinb8a4C2aH +Guu/xPc9RlsKJ9jC9ZjKJpxBmCG5vUTz6exjbNvnqKv6MIn3siW8GK1BlaWt7kA19Ih kBJ0wIwNdHfSRvoBU/9s0skP8J0n5OhzNSyyFiPgiFdpqNpdz2YtxEIVxSWuUGLhHZBs CXOz+6slCEydFlj30RonXdRjrhKog1GKX/H304Nf70sk5x4V+D/hjSii6qWxasMLKrMy nTemswneBuGfdonpoxqobbjJfh4Qnx1mL4bltc+Kdv2KbxCn4BwTMWwj0HI9DOkRrfEV C0CA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:message-id:date :subject:cc:to:from:sender:dkim-signature:dkim-signature; bh=y5FJYshjh2CMJEVybkUXiaR3mptxu2yDrf64SXTGIAc=; b=S5dJHpq3sKoz/N1dU5h9KMbr21OmUm5XUS7F6Ekwvw1V4ai5YM1YYtKa70JO8VIplA 8whOuu0hOcRs3Xk+PZ8QrmaM59lET7Go2gNAgcdldvW7aXujUngZrI3njstpuerq+GCV aNKO2j5ROb4jX3xwg/8NiiLxvFUaVyoxJcMFHh36UjuUUlFKh9oCE2idEfv1W/CfpofI 06kn23BC+2mmohelkhf1OVJOoazjrb6Nji0PQ36Bi1vvHzl7Xljb/0Cs5nfCCO2fVhmJ UYEjTBjcudz50hRcurxRrZIVmosZMBpywEC9g+OqSp4rJJSCsorPlaKSJ4eK/UpFpwxT /hQA== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=CgkYf5oC; spf=pass (google.com: domain of maly.smtp@gmail.com designates 2a00:1450:4864:20::42f as permitted sender) smtp.mailfrom=maly.smtp@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20221208; t=1685008311; x=1687600311; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:message-id:date:subject:cc:to:from :sender:from:to:cc:subject:date:message-id:reply-to; bh=y5FJYshjh2CMJEVybkUXiaR3mptxu2yDrf64SXTGIAc=; b=AjRoNLumPRziShBjNz8ShR7VKTqwN+C3TrCe6VhjO3FSnj7V9PSip2O54XlGj4b8ZK +81/JRqEnYv4W0V/9tdTtYWvVedPHCpnAfdjR9MbWbGsd5oENw79M0D309P7kc1Ti0Uv TviwUVbZLrlM1Y8o4rEUysw4f82CXcqlifCksYv89TQ6BtGlmd2jV4FWqlqqUEbPn68E wgHSbzP9qc+w5ygmQH0i7cuM5NUkBNgFOii5m0vIGTIzbeo1unBIEoTwOz6hWtxSjh9w 6xhMtUyCV0w+0CbylgKzr5is8cdsi80MbfOtjj6TvK+4HyBV0rQXEFY7i6ZeHsM31ebZ fv7A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685008311; x=1687600311; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:message-id:date:subject:cc:to:from :from:to:cc:subject:date:message-id:reply-to; bh=y5FJYshjh2CMJEVybkUXiaR3mptxu2yDrf64SXTGIAc=; b=Sr7PeCkrNnPti14AGxhIJh5K4Hoxl+RS4duS+e9z2+H3egQpaVS5Icj4tDANA4uBe7 vQGpIGJYjLgAv5uYNEQIINBaS6Pq/E2S3/tu2on8TRbF6lnbqcn6RpAvJraxrukYFE63 AGX7CP4WJ0W6swlX0Y90KaMRKe2XwrZL1tvlDuOFiNxDHhn1Ooef8InD/3yFQ0bwWwf5 P7BBPEsW+M30SsYdjA11yydIumNsy+t0h4sacCBlxaUkvPdZmiFKql4Heh4GPsP78m9Y wPeww58zNPNu514vm3/L4L4V1Jxy04NzM0i3FVyEpz+4A+xlxrT29SAaiKgnh+jZawja LFMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685008311; x=1687600311; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :message-id:date:subject:cc:to:from:x-beenthere:x-gm-message-state :sender:from:to:cc:subject:date:message-id:reply-to; bh=y5FJYshjh2CMJEVybkUXiaR3mptxu2yDrf64SXTGIAc=; b=R8A8I0TxzIGlLw28cyECcQ4vakhI+CjW/z1tFfFjsXnfaYdIoym52xu3JZH9dNgwxm fzkEClJYNLVELmCj8qnQSlLJJb7i5BrTlMgKIGaUUN8ugPu8kSlpKWQrVP/kplpJaq47 ptOddhxdXJQDPSWs6oMQI4rVyxfjo/HENhVirXdlbL7iyl8wxU2RZI/oO7Ol6ovTw6MN DOS7Mm2HZ3sMy7zGYIoTRWtad/Q104MdbJ23POwmkETAKzTeR9QrFfqfLYv0DlB1oRWW AHn0G7sOA+Ic9J5GWz1AIileYSJJZFyqb/2EZ5CKKMyRJ8xROeUVnlhRY8xX7705GzUt VDIA== Sender: swupdate@googlegroups.com X-Gm-Message-State: AC+VfDxLx8HnIRb8XQKrt5hHSLX16m3Nq6r6LVpdRO2apuuhhzy6mzaq lC7Lc6g2hAtCsJgRh8WT0MQ= X-Google-Smtp-Source: ACHHUZ4EwhomFW/1ivyWumPQbnyYKytmHBj2d3A06YhgYrjwJ1yiVcZ3lnGB7s2T6GSa049Qz7ud/g== X-Received: by 2002:a5d:4fcc:0:b0:309:45b2:50cb with SMTP id h12-20020a5d4fcc000000b0030945b250cbmr447493wrw.3.1685008310765; Thu, 25 May 2023 02:51:50 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:600c:3d98:b0:3f3:15ce:e16c with SMTP id bi24-20020a05600c3d9800b003f315cee16cls490131wmb.0.-pod-prod-01-eu; Thu, 25 May 2023 02:51:48 -0700 (PDT) X-Received: by 2002:a05:600c:3799:b0:3f6:938:1001 with SMTP id o25-20020a05600c379900b003f609381001mr1855309wmr.8.1685008308894; Thu, 25 May 2023 02:51:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685008308; cv=none; d=google.com; s=arc-20160816; b=XA4wBQJiNc4RtHU3++l0ZX/eaQ8dLcQYF3WwJL8YUo1e0j8swZ46CbwpFg3fZNYbLC mgqCzd0nM7XAN5X5wwwLNX3rZBfc6mJKEPd7ILndrY2uPNQDWf/Duo+tZQ3oKmg2RL00 cLcL72BTri76aZmAszAVzASgQ1Y/bcWneXXWUopREVNNlWNEfyD82hPLv7MbSTS8Lnwv T3enG4mBkBGmfGHuFSvnOCQVL4RXJyVBjvtGVQFlXzm28LqD55uijC5d790/rkBN3jVo J2cXfwuLJppkDxz3UDQ/L4FmV4MjlKzcv/Whi6zkUn0omsAbJlhyMvvrHJZ7A7s0CE4X F6JQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=kpxwfGtYzLQI2t58vyNmhwEEM+q+Z5pcC/Sb+pzrBJo=; b=wVB6BOlRb/OVByavkWPI1RnX+LlQpVhEsu620Um+clAk7ws36Val6G6kDxck6iE3b+ WF8yVvh5Vrxw4XKbHEdC5Z04uboQDFGIf7f2hncuR1sSu6JVot5no000x/ZiLc6dnKHD 73Rr6+K7szeBVIfJBNK60LUAeazMnugyz5knxLIR8/WktMWxPLUi1AKlex7b5v4Q90Mb rLXzG51IoQbEKWF+fV1Ywocx/GewEbiZJ6oq6rekRt47PvknhQg+JjYXzrM1HtABXv+W SCpkhrx7ODs3iUHb5j/o+LGQMiAPZzhsXtb5FNhrFNhtv4FO7srKM74QR3HIC3NqS3se JcVg== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=CgkYf5oC; spf=pass (google.com: domain of maly.smtp@gmail.com designates 2a00:1450:4864:20::42f as permitted sender) smtp.mailfrom=maly.smtp@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com. [2a00:1450:4864:20::42f]) by gmr-mx.google.com with ESMTPS id p12-20020a05600c1d8c00b003f42786c7b4si365192wms.0.2023.05.25.02.51.48 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 25 May 2023 02:51:48 -0700 (PDT) Received-SPF: pass (google.com: domain of maly.smtp@gmail.com designates 2a00:1450:4864:20::42f as permitted sender) client-ip=2a00:1450:4864:20::42f; Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-30948709b3cso1234289f8f.3 for ; Thu, 25 May 2023 02:51:48 -0700 (PDT) X-Received: by 2002:adf:cc81:0:b0:307:a8e8:ca80 with SMTP id p1-20020adfcc81000000b00307a8e8ca80mr1911215wrj.18.1685008308099; Thu, 25 May 2023 02:51:48 -0700 (PDT) Received: from ubuntu.localdomain (88-101-50-251.rcg.o2.cz. [88.101.50.251]) by smtp.gmail.com with ESMTPSA id k7-20020adfe3c7000000b003062b2c5255sm1238873wrm.40.2023.05.25.02.51.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 02:51:47 -0700 (PDT) From: Jakub Maly To: swupdate@googlegroups.com Cc: Jakub Maly Subject: [swupdate] [PATCH] Switched to one common machine for rpi Date: Thu, 25 May 2023 11:51:41 +0200 Message-Id: <20230525095141.104291-1-jakub.maly@tietoevry.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Original-Sender: maly.smtp@gmail.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=CgkYf5oC; spf=pass (google.com: domain of maly.smtp@gmail.com designates 2a00:1450:4864:20::42f as permitted sender) smtp.mailfrom=maly.smtp@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , From: Jakub Maly --- .../rpi-uboot-scr/files/boot.cmd.in | 2 +- .../rpi-uboot-scr/rpi-u-boot-scr.bbappend | 2 +- .../files/{raspberrypi3 => rpi}/fw_env.config | 0 .../base-files/{raspberrypi3 => rpi}/fstab | 2 +- .../update-image/raspberrypi3/emmcsetup.lua | 85 ---------- .../update-image/raspberrypi3/sw-description | 55 ------- .../raspberrypi3/sw-description.embscript | 145 ------------------ .../images/update-image/rpi/emmcsetup.lua | 0 .../images/update-image/rpi/sw-description | 52 +++++++ .../swupdate/raspberrypi3/swupdate.cfg | 47 ------ .../{raspberrypi3 => rpi}/09-swupdate-args | 6 +- .../swupdate/{raspberrypi3 => rpi}/defconfig | 2 +- .../swupdate/swupdate/rpi/swupdate.cfg | 41 +++++ recipes-support/swupdate/swupdate_%.bbappend | 1 + 14 files changed, 103 insertions(+), 337 deletions(-) rename recipes-bsp/libubootenv/files/{raspberrypi3 => rpi}/fw_env.config (100%) rename recipes-core/base-files/base-files/{raspberrypi3 => rpi}/fstab (87%) delete mode 100644 recipes-extended/images/update-image/raspberrypi3/emmcsetup.lua delete mode 100644 recipes-extended/images/update-image/raspberrypi3/sw-description delete mode 100644 recipes-extended/images/update-image/raspberrypi3/sw-description.embscript create mode 100644 recipes-extended/images/update-image/rpi/emmcsetup.lua create mode 100644 recipes-extended/images/update-image/rpi/sw-description delete mode 100644 recipes-support/swupdate/swupdate/raspberrypi3/swupdate.cfg rename recipes-support/swupdate/swupdate/{raspberrypi3 => rpi}/09-swupdate-args (69%) rename recipes-support/swupdate/swupdate/{raspberrypi3 => rpi}/defconfig (98%) create mode 100644 recipes-support/swupdate/swupdate/rpi/swupdate.cfg diff --git a/dynamic-layers/raspberrypi/recipes-bsp/rpi-uboot-scr/files/boot.cmd.in b/dynamic-layers/raspberrypi/recipes-bsp/rpi-uboot-scr/files/boot.cmd.in index 04cbd7b..8855f43 100644 --- a/dynamic-layers/raspberrypi/recipes-bsp/rpi-uboot-scr/files/boot.cmd.in +++ b/dynamic-layers/raspberrypi/recipes-bsp/rpi-uboot-scr/files/boot.cmd.in @@ -2,5 +2,5 @@ saveenv fdt addr ${fdt_addr} && fdt get value bootargs /chosen bootargs if env exists rpipart;then echo Booting from mmcblk0p${rpipart};else setenv rpipart 2;echo rpipart not set, default to ${rpipart};fi load mmc 0:${rpipart} ${kernel_addr_r} boot/@@KERNEL_IMAGETYPE@@ -setenv bootargs ${bootargs} root=/dev/mmcblk0p${rpipart} +setenv bootargs "${bootargs} root=/dev/mmcblk0p${rpipart}" @@KERNEL_BOOTCMD@@ ${kernel_addr_r} - ${fdt_addr} diff --git a/dynamic-layers/raspberrypi/recipes-bsp/rpi-uboot-scr/rpi-u-boot-scr.bbappend b/dynamic-layers/raspberrypi/recipes-bsp/rpi-uboot-scr/rpi-u-boot-scr.bbappend index ff7b487..cd1615f 100644 --- a/dynamic-layers/raspberrypi/recipes-bsp/rpi-uboot-scr/rpi-u-boot-scr.bbappend +++ b/dynamic-layers/raspberrypi/recipes-bsp/rpi-uboot-scr/rpi-u-boot-scr.bbappend @@ -1,3 +1,3 @@ FILESEXTRAPATHS:prepend := "${THISDIR}/files:" -COMPATIBLE = "raspberrypi3" +COMPATIBLE = "raspberrypi3 raspberrypi4 raspberrypi4-64" diff --git a/recipes-bsp/libubootenv/files/raspberrypi3/fw_env.config b/recipes-bsp/libubootenv/files/rpi/fw_env.config similarity index 100% rename from recipes-bsp/libubootenv/files/raspberrypi3/fw_env.config rename to recipes-bsp/libubootenv/files/rpi/fw_env.config diff --git a/recipes-core/base-files/base-files/raspberrypi3/fstab b/recipes-core/base-files/base-files/rpi/fstab similarity index 87% rename from recipes-core/base-files/base-files/raspberrypi3/fstab rename to recipes-core/base-files/base-files/rpi/fstab index 4f23935..7988617 100644 --- a/recipes-core/base-files/base-files/raspberrypi3/fstab +++ b/recipes-core/base-files/base-files/rpi/fstab @@ -1,4 +1,4 @@ -# stock fstab - you probably want to override this with a machine specific one +# default fstab for rpi boards /dev/root / auto defaults 1 1 proc /proc proc defaults 0 0 diff --git a/recipes-extended/images/update-image/raspberrypi3/emmcsetup.lua b/recipes-extended/images/update-image/raspberrypi3/emmcsetup.lua deleted file mode 100644 index 09d1fb7..0000000 --- a/recipes-extended/images/update-image/raspberrypi3/emmcsetup.lua +++ /dev/null @@ -1,85 +0,0 @@ -function os.capture(cmd) - local f = assert(io.popen(cmd, 'r')) - local s = assert(f:read('*a')) - f:close() - return s -end - -function file_exists(name) - local f=io.open(name,"r") - if f~=nil then io.close(f) return true else return false end -end - -function cmdexec(cmd) - local ret, s, status = os.execute(cmd) - if (status ~= 0) then - return false, cmd .. " return with error" - end - - return true,"" -end - -function preinst() - local out - local s1 - local ret - - local log = os.tmpname() - - local eMMC = "/dev/mmcblk0" - ret = file_exists("/dev/mmcblk0") - - if (ret == false) then - return false, "Cannot fine eMMC" - end - - cmdexec("/usr/sbin/sfdisk -d " .. eMMC .. "> /tmp/dumppartitions") - - -- check if there are two identical partitions - -- and create the second one if no available - f = io.input("/tmp/dumppartitions") - fo = io.output("/tmp/partitions") - t = f:read() - found = false - while (t ~= nil) do - j=0 - j=string.find(t, "/dev/mmcblk0p3") - fo:write(t .. "\n") - if (j == 1) then - found=true - break - end - j=string.find(t, "/dev/mmcblk0p2") - if (j == 1) then - start, size = string.match(t, "%a+%s*=%s*(%d+), size=%s*(%d+)") - end - t = f:read() - end - - if (found) then - f:close() - fo:close() - return true, out - end - - start=start+size - partitions = eMMC .. "p3 : start= " .. string.format("%d", start) .. ", size= " .. size .. ", type=83\n" - - fo:write(partitions) - fo:close() - f:close() - - out = os.capture("/usr/sbin/sfdisk --force " .. eMMC .. " < /tmp/partitions") - - -- use partprobe to inform the kernel of the new partitions - - cmdexec("/usr/sbin/partprobe " .. eMMC) - - return true, out -end - -function postinst() - local out = "Post installed script called" - - return true, out -end diff --git a/recipes-extended/images/update-image/raspberrypi3/sw-description b/recipes-extended/images/update-image/raspberrypi3/sw-description deleted file mode 100644 index f279d1a..0000000 --- a/recipes-extended/images/update-image/raspberrypi3/sw-description +++ /dev/null @@ -1,55 +0,0 @@ -software = -{ - version = "0.1.0"; - - raspberrypi3 = { - hardware-compatibility: [ "1.0"]; - stable : { - copy1 : { - images: ( - { - filename = "core-image-full-cmdline-raspberrypi3.ext4.gz"; - type = "raw"; - compressed = "zlib"; - device = "/dev/mmcblk0p2"; - } - ); - scripts: ( - { - filename = "emmcsetup.lua"; - type = "lua"; - } - ); - uboot: ( - { - name = "rpipart"; - value = "2"; - } - ); - - }; - copy2 : { - images: ( - { - filename = "core-image-full-cmdline-raspberrypi3.ext4.gz"; - type = "raw"; - compressed = "zlib"; - device = "/dev/mmcblk0p3"; - } - ); - scripts: ( - { - filename = "emmcsetup.lua"; - type = "lua"; - } - ); - uboot: ( - { - name = "rpipart"; - value = "3"; - } - ); - }; - }; - } -} diff --git a/recipes-extended/images/update-image/raspberrypi3/sw-description.embscript b/recipes-extended/images/update-image/raspberrypi3/sw-description.embscript deleted file mode 100644 index 7cf781f..0000000 --- a/recipes-extended/images/update-image/raspberrypi3/sw-description.embscript +++ /dev/null @@ -1,145 +0,0 @@ -software = -{ - version = "0.1.0"; - - raspberrypi3 = { - - embedded-script =" ---[[ - SWUpdate Embedded Script Example - Copyright (C) 2017, Stefano Babic - Description: - This is just an example how to integrate an embedded script in sw-description - The script is first parsed, be sure to escape double quotes - and use double quotes just when they are strictly required. - The script simply reads from a GPIO, and returns false if this GPIO - is set. That means: - GPIO(x)=0 ==> SWUpdate installs the SWU - GPIO(x)=1 ==> SWUpdate stops returning an error -]] --- Include swupdate library to use TRACE / ERROR -require (\"swupdate\") - -INPUT = 1 -OUTPUT = 0 - ---[[ - Some functions are simply retrieved from LUA examples - see book 'Programming in Lua' or some snipset from internet. -]] - -function file_exists(filename) - local file=io.open(filename,'r') - if file~=nil then io.close(file) return true else return false end -end - -function writeToFile (filename, data) - local file=io.open(filename, 'w') - file:write(data) - file:close() -end - -function readFromFile (filename) - if file_exists(filename) then - local file=io.open(filename, 'r') - local data = file:read(1) - file:close() - return data - else - return \"\" - end -end - -function pinMode(pin, mode) - local gpio_path = '/sys/class/gpio/' - local gpio_direction = gpio_path..'gpio'..pin..'/direction' - local gpio_export = gpio_path..'export' - - if not file_exists(gpio_direction) then - writeToFile(gpio_export,pin) - end - - if mode==INPUT then - writeToFile(gpio_direction, 'in') - else - writeToFile(gpio_direction, 'out') - end -end - -function digitalRead(pin) - value = readFromFile('/sys/class/gpio/gpio'..pin..'/value') - return tonumber(value) -end - -function allowInstall(image) - - -- Completely unuseful, but it is to show how to get values from image - - for k,l in pairs(image) do - swupdate.trace(\"image[\" .. tostring(k) .. \"] = \" .. tostring(l)) - end - - -- Read GPIO21, that means pin 40 on the Header - pinMode(21,INPUT) - val=digitalRead(21) - if (val == 0) then - swupdate.trace(\"Updated allowed: go on !\") - return true, image - else - swupdate.trace(\"Updated forbidden: STOP !\") - return false, image - end -end "; - - hardware-compatibility: [ "1.0"]; - stable : { - copy1 : { - images: ( - { - filename = "core-image-full-cmdline-raspberrypi3.ext4.gz"; - type = "raw"; - compressed = "zlib"; - device = "/dev/mmcblk0p2"; - hook = "allowInstall"; - } - ); - scripts: ( - { - filename = "emmcsetup.lua"; - type = "lua"; - } - ); - uboot: ( - { - name = "rpipart"; - value = "2"; - } - ); - - }; - copy2 : { - images: ( - { - filename = "core-image-full-cmdline-raspberrypi3.ext4.gz"; - type = "raw"; - compressed = "zlib"; - device = "/dev/mmcblk0p3"; - hook = "allowInstall"; - } - ); - scripts: ( - { - filename = "emmcsetup.lua"; - type = "lua"; - } - ); - uboot: ( - { - name = "rpipart"; - value = "3"; - } - ); - }; - }; - } -} diff --git a/recipes-extended/images/update-image/rpi/emmcsetup.lua b/recipes-extended/images/update-image/rpi/emmcsetup.lua new file mode 100644 index 0000000..e69de29 diff --git a/recipes-extended/images/update-image/rpi/sw-description b/recipes-extended/images/update-image/rpi/sw-description new file mode 100644 index 0000000..e584344 --- /dev/null +++ b/recipes-extended/images/update-image/rpi/sw-description @@ -0,0 +1,52 @@ +software = +{ + version = "0.1.0"; + + @@MACHINE@@ = { + hardware-compatibility: [ "1.0"]; + stable : { + copy1 : { + images: ( + { + filename = "core-image-full-cmdline-@@MACHINE@@.ext4.gz"; + type = "raw"; + compressed = "zlib"; + device = "/dev/mmcblk0p2"; + sha256 = "$swupdate_get_sha256(core-image-full-cmdline-@@MACHINE@@.ext4.gz)"; + } + ); + bootenv: ( + { + name = "rpipart"; + value = "2"; + }, + { + name = "ustate"; + value = "1"; + } + ); + }; + copy2 : { + images: ( + { + filename = "core-image-full-cmdline-@@MACHINE@@.ext4.gz"; + type = "raw"; + compressed = "zlib"; + device = "/dev/mmcblk0p3"; + sha256 = "$swupdate_get_sha256(core-image-full-cmdline-@@MACHINE@@.ext4.gz)"; + } + ); + bootenv: ( + { + name = "rpipart"; + value = "3"; + }, + { + name = "ustate"; + value = "1"; + } + ); + }; + }; + } +} diff --git a/recipes-support/swupdate/swupdate/raspberrypi3/swupdate.cfg b/recipes-support/swupdate/swupdate/raspberrypi3/swupdate.cfg deleted file mode 100644 index 5671fe3..0000000 --- a/recipes-support/swupdate/swupdate/raspberrypi3/swupdate.cfg +++ /dev/null @@ -1,47 +0,0 @@ -globals : -{ - - verbose = true; - loglevel = 5; - syslog = true; - /* public-key-file = "test.pem";*/ -}; - -download : -{ - retries = 3; - timeout = 1800; -}; - -identify : ( - { name = "raspberryPI3"; value = "1.0"; } -); - -suricatta : -{ - - tenant = "default"; - id = "raspberrypi3"; - confirm = 0; - url = "http://paperina2:8280"; - polldelay = 60; - nocheckcert = true; - retry = 4; - retrywait = 200; - loglevel = 10; - userid = 0; - groupid = 0; - max_artifacts = 1; -/* - cafile = "/etc/ssl/cafile"; - sslkey = "/etc/ssl/sslkey"; - sslcert = "/etc/ssl/sslcert"; -*/ -}; - -webserver : -{ - document_root = "/www"; - userid = 0; - groupid = 0; -}; diff --git a/recipes-support/swupdate/swupdate/raspberrypi3/09-swupdate-args b/recipes-support/swupdate/swupdate/rpi/09-swupdate-args similarity index 69% rename from recipes-support/swupdate/swupdate/raspberrypi3/09-swupdate-args rename to recipes-support/swupdate/swupdate/rpi/09-swupdate-args index 243aded..253de4c 100644 --- a/recipes-support/swupdate/swupdate/raspberrypi3/09-swupdate-args +++ b/recipes-support/swupdate/swupdate/rpi/09-swupdate-args @@ -7,6 +7,10 @@ else fi state=`fw_printenv ustate | cut -f 2 -d'='` +if [ -z "$state" ];then + fw_setenv ustate 1 + state=`fw_printenv ustate | cut -f 2 -d'='` +fi if [ $state == 1 ];then SWUPDATE_SURICATTA_ARGS="-c 2" else @@ -19,4 +23,4 @@ else CFGFILE="/etc/swupdate.cfg" fi -SWUPDATE_ARGS="-H raspberrypi3:1.0 ${selection} -f ${CFGFILE}" +SWUPDATE_ARGS="-H @MACHINE@:1.0 ${selection} -p 'reboot' -f ${CFGFILE}" diff --git a/recipes-support/swupdate/swupdate/raspberrypi3/defconfig b/recipes-support/swupdate/swupdate/rpi/defconfig similarity index 98% rename from recipes-support/swupdate/swupdate/raspberrypi3/defconfig rename to recipes-support/swupdate/swupdate/rpi/defconfig index fd8ce63..03cfd7e 100644 --- a/recipes-support/swupdate/swupdate/raspberrypi3/defconfig +++ b/recipes-support/swupdate/swupdate/rpi/defconfig @@ -59,7 +59,7 @@ CONFIG_DOWNLOAD=y # CONFIG_DOWNLOAD_SSL is not set CONFIG_CHANNEL_CURL=y CONFIG_HASH_VERIFY=y -# CONFIG_SIGNED_IMAGES is not set +CONFIG_SIGNED_IMAGES=y CONFIG_ENCRYPTED_IMAGES=y CONFIG_SURICATTA=y diff --git a/recipes-support/swupdate/swupdate/rpi/swupdate.cfg b/recipes-support/swupdate/swupdate/rpi/swupdate.cfg new file mode 100644 index 0000000..4b8a582 --- /dev/null +++ b/recipes-support/swupdate/swupdate/rpi/swupdate.cfg @@ -0,0 +1,41 @@ +globals : +{ + verbose = true; + loglevel = 5; + syslog = true; + public-key-file = "@PUBKEY@"; +}; + +download : +{ + retries = 3; + timeout = 1800; +}; + +identify : ( + { name = "raspberryPI"; value = "1.0"; } +); + +suricatta : +{ + enable = true; + tenant = "default"; + id = "@TARGETID@"; + url = "@PROTOCOL@://@HOSTNAME@:@PORT@"; + polldelay = 60; + nocheckcert = true; + retry = 4; + retrywait = 200; + loglevel = 10; + userid = 0; + groupid = 0; + targettoken = "@TARGETTOKEN@"; +}; + +webserver : +{ + document_root = "/www"; + userid = 0; + groupid = 0; + timeout = 20; +}; diff --git a/recipes-support/swupdate/swupdate_%.bbappend b/recipes-support/swupdate/swupdate_%.bbappend index b6d09c5..b1b9390 100644 --- a/recipes-support/swupdate/swupdate_%.bbappend +++ b/recipes-support/swupdate/swupdate_%.bbappend @@ -11,6 +11,7 @@ SRC_URI:append:beaglebone-yocto = " file://10-remove-force-ro" do_install:append() { install -m 0644 ${WORKDIR}/09-swupdate-args ${D}${libdir}/swupdate/conf.d/ + sed -i "s#@MACHINE@#${MACHINE}#g" ${D}${libdir}/swupdate/conf.d//09-swupdate-args install -d ${D}${sysconfdir} install -m 644 ${WORKDIR}/swupdate.cfg ${D}${sysconfdir}