u-boot script to allow choosing between which rootfs part to boot (RAUC) - yocto

I've managed to create an image with two rootfs partitions to run on my jetson nano with yocto/poky. I've followed the meta-rauc layer README and rauc user manual, to create the system.conf file and rauc_%.bbappend file and I am able to create bundles successfully.
As I understand, I need some sort of u-boot script:
In order to enable RAUC to switch the correct slot, its system configuration must specify the name of the respective slot from the bootloader’s perspective. You also have to set up an appropriate boot selection logic in the bootloader itself, either by scripting (as for GRUB, U-Boot) or by using dedicated boot selection infrastructure (such as bootchooser in Barebox).
The bootloader must also provide a set of variables the Linux userspace can modify in order to change boot order or priority.
Having this interface ready, RAUC will care for setting the boot logic appropriately. It will, for example, deactivate the slot to update before writing to it and reactivate it after having completed the installation successfully.
Do I make a script somewhere in the yocto layer or build folder or is it a script i need to put on the jetson nano after making the image? - and what would the contents of this script be?
**************************************************EDIT********************************************************
I've made this script:
test -n "${BOOT_ORDER}" || setenv BOOT_ORDER "system0 system1"
test -n "${BOOT_system0_LEFT}" || setenv BOOT_system0_LEFT 3
test -n "${BOOT_system1_LEFT}" || setenv BOOT_system1_LEFT 3
setenv bootargs
for BOOT_SLOT in "${BOOT_ORDER}"; do
if test "x${bootargs}" != "x"; then
# skip remaining slots
elif test "x${BOOT_SLOT}" = "xsystem0"; then
if test ${BOOT_system0_LEFT} -gt 0; then
setexpr BOOT_system0_LEFT ${BOOT_system0_LEFT} - 1
echo "Found valid slot system0, ${BOOT_system0_LEFT} attempts remaining"
setenv distro_bootpart "1"
setenv boot_line "mmc 1:1 any ${scriptaddr} /boot/extlinux/extlinux.conf"
setenv bootargs "${default_bootargs} root=/dev/mmcblk0p1 rauc.slot=system0"
fi
elif test "x${BOOT_SLOT}" = "xsystem1"; then
if test ${BOOT_system1_LEFT} -gt 0; then
setexpr BOOT_system1_LEFT ${BOOT_system1_LEFT} - 1
echo "Found valid slot system1, ${BOOT_system1_LEFT} attempts remaining"
setenv distro_bootpart "13"
setenv boot_line "mmc 1:D any ${scriptaddr} /boot/extlinux/extlinux.conf"
setenv bootargs "${default_bootargs} root=/dev/mmcblk0p13 rauc.slot=system1"
fi
fi
done
if test -n "${bootargs}"; then
saveenv
else
echo "No valid slot found, resetting tries to 3"
setenv BOOT_system0_LEFT 3
setenv BOOT_system1_LEFT 3
saveenv
reset
fi
sysboot ${boot_line}
And I i got this recipe recipes-bsp/u-boot/u-boot-script.bb in my meta-layer:
LICENSE = "GPLv2+"
LIC_FILES_CHKSUM = "file://Licenses/README;md5=30503fd321432fc713238f582193b78e"
S = "${WORKDIR}/git"
PACKAGE_ARCH = "${MACHINE_ARCH}"
DEPENDS = "u-boot-mkimage-native"
inherit deploy
BOOTSCRIPT ??= "${THISDIR}/uboot.sh"
do_mkimage () {
uboot-mkimage -A arm -O linux -T script -C none -a 0 -e 0 \
-n "boot script" -d ${BOOTSCRIPT} ${S}/boot.scr
}
addtask mkimage after do_compile before do_install
do_compile[noexec] = "1"
do_install () {
install -D -m 644 ${S}/boot.scr ${D}/boot.scr
}
do_deploy () {
install -D -m 644 ${D}/boot.scr \
${DEPLOYDIR}/boot.scr-${MACHINE}-${PV}-${PR}
cd ${DEPLOYDIR}
rm -f boot.scr-${MACHINE}
ln -sf boot.scr-${MACHINE}-${PV}-${PR} boot.scr-${MACHINE}
}
addtask deploy after do_install before do_build
FILES_${PN} += "/"
COMPATIBLE_MACHINE = "jetson-nano"
I can see that the script image is getting into work/jetson_nano_poky-linux/u-boot-tegra/2016.07.../git/ folder.
But how do I use it in u-boot? - How do i make sure this script is run automatically every boot?

U boot part of the default boot sequence tries to find a file named boot.src in the first partition from where it has booted.
if this file is found then it will try to run this script.
The commands put in the file can be based on RAUC syntax so that when RAUC gets activated in the user space it can update the same environment variables.
So RAUC handles the boot sequence via the commands put int the script file. RAUC has no way to directly alter the flow of U Boot boot up sequence

Related

Unsupported Architectures .frameworks

I'm using commoncrypto. I added this using carthage. I added the run script. I embed & sign Framework. I also added code to the run script. When I try to install the app in the apple store, I get the error in the photo below. I added framework to input and output. What is the problem?
if [ "${CONFIGURATION}" = "Release" ]; then
APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
# This script loops through the frameworks embedded in the application and
# removes unused architectures.
find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
do
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"
EXTRACTED_ARCHS=()
for ARCH in $ARCHS
do
echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"
lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
done
echo "Merging extracted architectures: ${ARCHS}"
lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[#]}"
rm "${EXTRACTED_ARCHS[#]}"
echo "Replacing original executable with thinned version"
rm "$FRAMEWORK_EXECUTABLE_PATH"
mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"
done
fi
Where did you put the script to eliminate i386?
Did you try to download the CommonCrypto.framework.zip file then drag and drop directly to your project?

How to execute a script in swupdate image recipe in Yocto?

I am unable to execute a shell script(create_signed_swu.sh) in my recipe(panther2-swu.bb) which inherit swupdate and if I remove inherit swupdate, I see do_compile gets compiled and script executes successfully.
Here is panther2-swu.bb recipe:
DESCRIPTION = "Building swupdate image (.swu ) for panther2 board"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
inherit swupdate
FILESEXTRAPATHS_append := "${THISDIR}/../../../../build/tmp/deploy/images/panther2/"
SRC_URI = "file://sw-description \
file://postinstall_swu.sh \
file://bzImage \
file://create_signed_swu.sh \
file://priv.pem \
file://passphrase \
"
do_compile() {
${WORKDIR}/create_signed_swu.sh
}
DEPENDS = "openssl-native"
Here is the create_signed_swu.sh:
#!/bin/bash
IMAGES="bzImage panther2-usb-panther2.ext4"
FILES="sw-description sw-description.sig postinstall_swu.sh $IMAGES"
echo "Executing swu signing script..."
cp ../sw-description .
cp ../postinstall_swu.sh .
cp ../../../../../deploy/images/panther2/bzImage .
cp ../../../../../deploy/images/panther2/panther2-usb-panther2.ext4 .
read -d ' ' SHA_ROOTFS < <(sha256sum panther2-usb-panther2.ext4)
read -d ' ' SHA_BZIMAGE < <(sha256sum bzImage)
read -d ' ' SHA_POSTINSTALL < <(sha256sum postinstall_swu.sh)
sed -i ':a;N;$!ba; s/sha256 = "[0-9A-Za-z]*"/sha256 = '"\"${SHA_ROOTFS}"\"'/1' sw-description
sed -i ':a;N;$!ba; s/sha256 = "[0-9A-Za-z]*"/sha256 = '"\"${SHA_BZIMAGE}"\"'/2' sw-description
sed -i ':a;N;$!ba; s/sha256 = "[0-9A-Za-z]*"/sha256 = '"\"${SHA_POSTINSTALL}"\"'/3' sw-description
openssl dgst -sha256 -sign ../priv.pem -passin file:../passphrase sw-description > sw-description.sig
for i in $FILES;do
echo $i;done | cpio -ov -H crc > panther2-swu-$USER-devbuild.swu
cp panther2-swu-$USER-devbuild.swu ../../../../../deploy/images/panther2
rm -f sw-description
rm -f postinstall_swu.sh
rm -f sw-description.sig
rm -f bzImage
rm -f panther2-usb-panther2.ext4
rm -f panther2-swu-$USER-devbuild.swu
I have tried ROOTFS_POSTPROCESS_COMMAND as well but it doen't execute my srcipt either.
Any help would really be appreciated, Thanks in advance...!!!
If removing the inherit swupdate makes your do_compile execute and launch your script it means that the class swupdate.bbclass do not execute the do_compile task.
The class surely has this line :
do_compile[noexec] = "1"
Which means that the do_compile is not excuted at all.
You could choose between two solutions:
Using prepend/append of some task:
Prepend/append your recipe's task that is meant to launch the script to an existing task like following :
Assuming the do_configure is launched :
do_configure_append()
{
${WORKDIR}/create_signed_swu.sh
}
This will launch your script at the end of do_configure.
Creating your own task:
Assuming you want to launch your script before do_build task
do_launch_script () {
${WORKDIR}/create_signed_swu.sh
}
addtask launch_script after do_configure before do_build
Generating a SWU does not compile anything and not only do_compile, but even do_configure is turned off. The class "swupdate" has an own task : do_swuimage. Changes to default behaviour can be done with a do_swuimage_append().
Anyway, the script above makes no sense: the class does exactly what the script is trying to do, and provide variable substitutions to automatically set sha256 and other values. The "sed" entries make no sense, as well as signing in this script. Instead of that, the class should be inherited and variables must be (all of them starting with SWUPDATE_, please check in documentation) to let the class to do its job. The script is a variant of the script inserted in the documentation to build outside Yocto - instead of following this approach, the functionalities in meta-swupdate should be used.

Where do I find alias arguments in fastlane?

In a fastlane project that I am taking over everything is run by command line (e.g. not fastfile). In this project (using fastlane 1.7) there are aliases used for arguments. Where would I go to find out what each of the aliases map to as far as fastlane commands? For example:
def build(Myapp, skip_profile)
if skip_profile || download_provisioning_profiles(MyApp)
build_cmd = "gym -a -r -s #{MyApp.name} -o ./build -n #{MyApp.ipa_name} --use_legacy_build_api"
system(build_cmd)
else
puts "Was unable to install provisioning profiles"
exit 1
end
end
Looking at this I am pretty sure that -o is the output but where would I look to find out explicitly what -a and -r and -s and -o are?
Run
fastlane gym --help
to get a list of all available options for the gym tool.

Start shrew vpn client (iked & ikec) on start-up of OSMC on Raspberry 2

I would like to connect to a VPN on start-up of OSMC.
Environment:
installed OSMC on Raspberry 2
downloaded, compiled and installed shrew soft vpn on the device
As user 'osmc' with ssh
> sudo iked starts the daemon successfully
> ikec -r "test.vpn" -a starts the client, loads the config and connects successfully
rc.local:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
sudo iked >> /home/osmc/iked.log 2>> /home/osmc/iked.error.log &
ikec -a -r "test.vpn" >> /home/osmc/ikec.log 2>> /home/osmc/ikec.error.log &
exit 0
after start of raspberry iked is as process visible with ps -e
but ikec is not running
osmc#osmc:~$ /etc/rc.local starts the script and connects to vpn successfully
Problem:
Why does the script not working correctly on start-up?
Thank you for your help!
I was also looking to do the same thing as you and ran into the same problem. I'm no linux expert, but I did figure out a workaround.
I created a script called ikec_after_reboot.sh and it looks like this...
$ cat ikec_after_reboot.sh
#!/bin/bash
echo "Starting ikec"
ikec -r test.vpn -a
I then installed cron.
sudo apt-get update
sudo apt-get install cron
Edit the cron job as root and run the ikec script 60 seconds after reboot.
sudo crontab -e
SHELL=/bin/bash
#reboot sleep 60 && /home/osmc/ikec_after_reboot.sh & >> /home/osmc/ikec.log 2>&1
Now edit your /etc/rc.local file and add the following.
sudo iked >> //home/osmc/iked.log 2>> /home/osmc/iked.error.log &
exit 0
Hopefully, this is helpful to you.

rpm build fails to make build root dir

I am working on making an rpm for a small program used within our enterprise. The %build section of the rpm process works. I'm having trouble with the install section. I've referenced this article response and I believe I am properly referring to the target location with respect to %{_buildroot}.
The program I'm making is to be installed as a system service. So, after the rpm actually is generated for this step, I've got to add the next step in my installation process which is to include the script that is installed to the init.d location and run that install. One step at a time though.
The build errors are as follows (omitting everything but %install):
Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.eUDaCK
+ umask 022
+ cd /home/packager/rpmbuild/BUILD
+ '[' /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64 '!=' / ']'
+ rm -rf /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64
++ dirname /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64
+ mkdir -p /home/packager/rpmbuild/BUILDROOT
+ mkdir /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64
+ cd o2arbitord-1.0
+ LANG=C
+ export LANG
+ unset DISPLAY
+ install -m 555 /home/packager/rpmbuild/BUILD/o2arbitord-1.0/o2arbitord /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64/usr/sbin
install: cannot create regular file `/home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64/usr/sbin': No such file or directory
error: Bad exit status from /var/tmp/rpm-tmp.eUDaCK (%install)
Now, my rpmbuild directory does not have the directory /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64/usr/sbin. While I know that's part of the problem, the rpmbuild process isn't making the directory /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64 either. What I don't understand about that one is: why? Looking at the script output above you can clearly see the line: mkdir /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64. So, why isn't the directory made?
How does the line BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) from whatever the definition of %{_buildroot} is? I thought that was the definition, but it appears to be something different.
For reference, my spec file
Name: o2arbitord
Version: 1.0
Release: 1%{?dist}
Summary: a daemon
Group: Applications/System
License: GPL
URL: http://My.site
Source0: %{name}-%{version}.tar.gz
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
BuildArch: x86_64
BuildRequires: libusb1-devel
#Requires:
%description
%prep
%setup -q
%build
make -f o2arbitord.mk
%install
install -m 555 %{_builddir}/%{name}-%{version}/%{name} %{buildroot}%{_sbindir}
%clean
rm -rf %{buildroot}
%files
%defattr(-,root,root,-)
/usr/sbin/o2arbitord
%changelog
You are attempting to install a file into a directory that doesn't exist (yet).
RPM only creates the %{buildroot} for you automatically. Anything under that you need to create yourself.
So when you run
install -m 555 %{_builddir}/%{name}-%{version}/%{name} %{buildroot}%{_sbindir}
where %{buildroot}%{_sbindir} expands to /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64/usr/sbin RPM has only created /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64 for you already.
You need to create the /usr/sbin part of that path and then copy the file into it.
You can do that with either
%{__mkdir_p} '%{buildroot}%{_sbindir}'
or
%{__install} -d '%{buildroot}%{_sbindir}'
Where
$ rpm -E '__mkdir_p = %{__mkdir_p}'
__mkdir_p = /bin/mkdir -p
$ rpm -E '__install = %{__install}'
__install = /usr/bin/install