BIOS design using PETITBOOT to support SPI booting

Moderators: mdrjr, odroid

BIOS design using PETITBOOT to support SPI booting

Unread postby joy » Sat Nov 03, 2018 1:59 pm

Hi all,

About spi booting, there are many discussions about HW configuration, bios approaches and booting process design.
viewtopic.php?f=155&t=30698
viewtopic.php?f=155&t=29976

Regardless of ODROID-N1, I'm interested in boot bios designed like petitboot and we couldn't complete SPI booting logic to run 2nd boot storage flexibly on ODROID-N1, so I'm working a bios approach using PETITBOOT on ODROID-N1.

I'm done making uInitrd image including petitboot and related packages
and adjust kernel configuration.
It works basically but there are some issues.

1. Issue 1 - Very late jump time to 2nd booting
Throught petitboot, we can jump to next booting to 2nd kernel and root file system from 2nd storage like usb or sata.
But the problem is I have to wait to load 2nd kernel.
Currently, it takes about 5~10 seconds till I can get 2nd kernel booting log. :(
I couldn't how I can figure out to optimize the waiting time.
2. Issue 2 - 2nd DTB load
I want to load different dts options flexibly but, it seems dtb option of petitboot and kexec doesn't work as I expected.
3. Issues 3 - Size option with small size SPI NAND/NOR
About this issue, I've tried to remove redundant kernel features and ramdisk utility/library
and I think it may be possible to fit in 8MB SPI storage.


So I wanna share my current status and ask opinions from brilliant and much experienced users here in ODROID forum.

I will focus on bios operation using petitbot first,
so let's forget how to run SPI boot and load images from the SPI storage,
and assume 1st kernel, dtb and ramdisk images are loaded from vfat area of eMMC or SD card.

    Step 1. How to generate uInitrd for petitboot
    Step 2. Kernel Configuration
    Step 3. Booting from 1st storage and Load petitboot application
    Step 4. Add a boot option and Jump to 2nd kernel from 2nd storage
    And Issues/TODO

=================================================================================================
(updated 2018/11/08, 08:00AM)
The uInitrd generation guide has been updated.
- some more missing parts are added with the latest packages.
- uInitrd auto build script is added.
- Copy routine of petitboot has been adjusted.


[ Step 1. How to generate uInitrd for petitboot ]
Here is an instruction to build-up uInitrd.
All binaries are needed to be compiled as 64-bit/ARM aarch64 objects and aarch64 libraries are also included initramfs,
So please run the following instructions on 64bit ARM board like N1 or C2.
I made it on N1 board.

[ References ]

[ Prebuilt Image ]
Here, you can find a reference uInitrd image made using this instructions.
https://dn.odroid.com/RK3399/Petitboot/uInitrd

[ Auto-install Script ]
Or, you can download an auto-installation script here.
Thank you! @elatllat
Code: Select all
# wget https://dn.odroid.com/RK3399/Petitboot/make_uInitrd.sh
# chmod a+x make_uInitrd.sh
# ./make_uInitrd.sh

If you want to follow the whole installation instructions manually, please refer to the next steps.

1. Dependency Build

(1) Preparations
Prepare a N1 debian image card.
https://www.odroid.in/odroid_n1/

Please run apt-get update and upgrade.
Code: Select all
$ sudo apt-get update -y && apt-get upgrade -y && apt-get dist-upgrade -y
$ sudo reboot


Then, install the following packages first.
Code: Select all
$ sudo apt-get install git -y
$ sudo apt-get install autoconf automake autopoint libtool pkg-config -y
$ sudo apt-get install libudev-dev libdevmapper-dev flex bison gettext -y
$ sudo apt-get install intltool libgcrypt20-dev -y
$ sudo apt-get install gperf libcap-dev libblkid-dev libmount-dev -y
$ sudo apt-get install xsltproc docbook-xsl docbook-xml python-lxml -y
$ sudo apt-get install libncurses5-dev libncursesw5-dev -y
$ sudo apt-get install libdw-dev libgpgme-dev -y

And make an empty working space.
Code: Select all
$ cd /home/odroid
$ mkdir ramdisk_petitboot
$ cd ramdisk_petitboot


(2) Download and Build systemd
Code: Select all
$ mkdir systemd
$ cd systemd
$ git clone git://anongit.freedesktop.org/systemd/systemd
$ cd systemd
$ ./autogen.sh
$ mkdir build
$ cd build
$ ../configure --prefix=/usr --enable-blkid --disable-seccomp --disable-libcurl --disable-pam --disable-kmod
$ make -j`nproc`
$ cd ../../..

(3) Download and Build kexec userspace utilities
Code: Select all
$ mkdir kexec
$ cd kexec
$ git clone git://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git
$ cd kexec-tools
$ ./bootstrap
$ ./configure --prefix=/usr
$ make -j`nproc`
$ cd ../..



2. Build Petitboot and Busybox

(1) Download and Build twin
Code: Select all
$ mkdir petitboot
$ cd petitboot
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/geoff/libtwin.git
$ cd libtwin
$ ./autogen.sh
$ make
$ make install
$ cd ../..

(2) Download and Build petitboot
Code: Select all
$ cd petitboot
$ git clone https://github.com/open-power/petitboot.git
$ cd petitboot

Current version I'm using is the latest one of branch, petitboot-1.6.x.
Code: Select all
$ git checkout --track origin/petitboot-1.6.x

Then, build it.
Code: Select all
$ ./bootstrap
$ ./configure --with-twin-x11=no --with-twin-fbdev=no --with-signed-boot=no --disable-nls
$ make -j`nproc`
$ cd ../..

(3) Download and Build busybox
Code: Select all
$ mkdir busybox
$ cd busybox
$ git clone git://git.busybox.net/busybox
$ cd busybox
$ make defconfig
$ LDFLAGS=--static make -j`nproc`
$ cd ../..


3. Build initramfs

(1) Prepare the skeleton directory structure
Code: Select all
$ mkdir initramfs
$ mkdir -p initramfs/{bin,sbin,etc,lib,proc,sys,newroot,usr,usr/bin,usr/sbin,var,var/log,run,run/udev,tmp}
$ mkdir initramfs/var/log/petitboot
$ touch initramfs/etc/mdev.conf
$ cp -Rp /lib/terminfo initramfs/lib/
$ cp -Rp busybox/busybox/busybox initramfs/bin/
$ ln -s busybox initramfs/bin/sh

(2) Copy core libraries to the new initramfs
Code: Select all
$ mkdir -p initramfs/lib/aarch64-linux-gnu
 
$ cp -L /lib/aarch64-linux-gnu/libc.so.* initramfs/lib/aarch64-linux-gnu/
$ cp -L /lib/aarch64-linux-gnu/libm.so.* initramfs/lib/aarch64-linux-gnu/
$ cp -L /lib/aarch64-linux-gnu/libdl.so.* initramfs/lib/aarch64-linux-gnu/
$ cp -L /lib/aarch64-linux-gnu/librt.so.* initramfs/lib/aarch64-linux-gnu/
$ cp -R /lib/aarch64-linux-gnu/libacl.so.* initramfs/lib/aarch64-linux-gnu/
$ cp -R /lib/aarch64-linux-gnu/libcap.so.* initramfs/lib/aarch64-linux-gnu/
$ cp -R /lib/aarch64-linux-gnu/libattr.so.* initramfs/lib/aarch64-linux-gnu/
$ cp -L /lib/aarch64-linux-gnu/libpthread.so.* initramfs/lib/aarch64-linux-gnu/
$ cp -R /lib/aarch64-linux-gnu/libncurses.so.* initramfs/lib/aarch64-linux-gnu/
$ cp -R /lib/aarch64-linux-gnu/libncursesw.so.* initramfs/lib/aarch64-linux-gnu/         # <<<---------- added
$ cp -R /lib/aarch64-linux-gnu/libtinfo.so.* initramfs/lib/aarch64-linux-gnu/
$ cp -R /lib/aarch64-linux-gnu/libpcre.so.* initramfs/lib/aarch64-linux-gnu/
$ cp -L /lib/aarch64-linux-gnu/libresolv.so.* initramfs/lib/aarch64-linux-gnu/
$ cp -R /lib/aarch64-linux-gnu/libselinux.so.* initramfs/lib/aarch64-linux-gnu/
$ cp -R /lib/aarch64-linux-gnu/libreadline.so.* initramfs/lib/aarch64-linux-gnu/
$ cp -R /lib/aarch64-linux-gnu/libgcc_s.so.* initramfs/lib/aarch64-linux-gnu/
$ cp -R /lib/aarch64-linux-gnu/libblkid.so.* initramfs/lib/aarch64-linux-gnu/
$ cp -R /lib/aarch64-linux-gnu/libkmod.so.* initramfs/lib/aarch64-linux-gnu/
$ cp -R /lib/aarch64-linux-gnu/libuuid.so.* initramfs/lib/aarch64-linux-gnu/
$ cp -R /lib/aarch64-linux-gnu/libusb-1.0.so.* initramfs/lib/aarch64-linux-gnu/
$ cp -R /lib/aarch64-linux-gnu/libdevmapper.so.* initramfs/lib/aarch64-linux-gnu/
$ cp -R /lib/aarch64-linux-gnu/libz.so.* initramfs/lib/aarch64-linux-gnu/
$ cp -R /lib/aarch64-linux-gnu/liblzma.so.* initramfs/lib/aarch64-linux-gnu/
$ cp -R /lib/aarch64-linux-gnu/libbz2.so.* initramfs/lib/aarch64-linux-gnu/
$ cp -R /lib/aarch64-linux-gnu/libgpg-error.so.* initramfs/lib/aarch64-linux-gnu/
$ cp -L /lib/aarch64-linux-gnu/libnss_files.so.* initramfs/lib/aarch64-linux-gnu/
 
$ mkdir -p initramfs/lib/
$ cp -L /lib/ld-linux-aarch64.so.* initramfs/lib/
 
$ mkdir -p initramfs/usr/lib/aarch64-linux-gnu/
$ cp -R /usr/lib/aarch64-linux-gnu/libform.so.* initramfs/usr/lib/aarch64-linux-gnu/
$ cp -R /usr/lib/aarch64-linux-gnu/libformw.so.* initramfs/usr/lib/aarch64-linux-gnu/           #   <<<----- added
$ cp -R /usr/lib/aarch64-linux-gnu/libmenu.so.* initramfs/usr/lib/aarch64-linux-gnu/
$ cp -R /usr/lib/aarch64-linux-gnu/libmenuw.so.* initramfs/usr/lib/aarch64-linux-gnu/          #   <<<----- added
$ cp -L /usr/lib/aarch64-linux-gnu/libelf.so.* initramfs/usr/lib/aarch64-linux-gnu/
$ cp -L /usr/lib/aarch64-linux-gnu/libdw.so.* initramfs/usr/lib/aarch64-linux-gnu/
$ cp -R /usr/lib/aarch64-linux-gnu/libgpgme.so.* initramfs/usr/lib/aarch64-linux-gnu/
$ cp -R /usr/lib/aarch64-linux-gnu/libassuan.so.* initramfs/usr/lib/aarch64-linux-gnu/

(3) Copy the helper binaries to the new initramfs
Code: Select all
$ cp -Rp /usr/bin/gpg initramfs/usr/bin/
 
$ cp systemd/systemd/build/.libs/libudev.so.* initramfs/lib/aarch64-linux-gnu/
$ cp -Rp systemd/systemd/build/systemd-udevd initramfs/sbin/
$ cp -Rp systemd/systemd/build/udevadm initramfs/sbin/
 
$ mkdir -p initramfs/usr/lib/udev
$ cp -Rp systemd/systemd/build/*_id initramfs/usr/lib/udev
 
$ cp -Rp kexec/kexec-tools/build/sbin/kexec initramfs/sbin/


(4) Install petitboot itself to the initramfs
Code: Select all
$ cd petitboot/petitboot
$ make DESTDIR=`realpath ../../initramfs/` install
$ cd ../..

(5) Copy udev rules the new initramfs
Code: Select all
$ mkdir -p initramfs/usr/lib/udev/rules.d
$ cp -Rp systemd/systemd/rules/* initramfs/usr/lib/udev/rules.d/
$ cp -Rp systemd/systemd/build/rules/* initramfs/usr/lib/udev/rules.d/
$ rm -f initramfs/usr/lib/udev/rules.d/*-drivers.rules

(6) Set up udncp helper scripts
Code: Select all
$ mkdir -p initramfs/usr/share/udhcpc/
$ cp -Rp busybox/busybox/examples/udhcp/simple.script initramfs/usr/share/udhcpc/simple.script
$ chmod 755 initramfs/usr/share/udhcpc/simple.script

$ sed -i '/should be called from udhcpc/d' initramfs/usr/share/udhcpc/simple.script

$ cat << EOF > initramfs/usr/share/udhcpc/default.script
#!/bin/sh

/usr/share/udhcpc/simple.script "\$@"
/usr/sbin/pb-udhcpc "\$@"
EOF

$ chmod 755 initramfs/usr/share/udhcpc/default.script

(7) Set up nsswitch
Code: Select all
$ touch initramfs/etc/nsswitch.conf

$ cat << EOF > initramfs/etc/nsswitch.conf
passwd:                files
group:                files
shadow:                files
hosts:                files
networks:        files
protocols:        files
services:        files
ethers:                files
rpc:                files
netgroup:        files
EOF

(8) Add basic groups
Code: Select all
$ touch initramfs/etc/group
$ cat << EOF > initramfs/etc/group
root:x:0:
daemon:x:1:
tty:x:5:
disk:x:6:
lp:x:7:
kmem:x:15:
dialout:x:20:
cdrom:x:24:
tape:x:26:
audio:x:29:
video:x:44:
input:x:122:
EOF

(9) Create boot script
Code: Select all
$ vi initramfs/init

#!/bin/sh

/bin/busybox --install -s

CURRENT_TIMESTAMP=\$(date '+%s')
if [ \$CURRENT_TIMESTAMP -lt `date '+%s'` ]; then
        date -s "@`date '+%s'`"
fi

mount -t proc proc /proc
mount -t sysfs sysfs /sys
mount -t devtmpfs none /dev
 
echo 0 > /proc/sys/kernel/printk
clear
 
systemd-udevd &
udevadm hwdb --update
udevadm trigger

pb-discover &
petitboot-nc
 
if [ -e /etc/pb-lockdown ]; then
        echo "Failed to launch petitboot, rebooting!"
        echo 1 > /proc/sys/kernel/sysrq
        echo b > /proc/sysrq-trigger
else
        echo "Failed to launch petitboot, dropping to a shell"
        exec sh
fi
 
$ chmod +x initramfs/init


(10) Strip debug symbols from files installed in the initramfs
Code: Select all
$ strip initramfs/sbin/*
$ strip initramfs/usr/sbin/*
$ strip initramfs/lib/aarch64-linux-gnu/*
$ strip initramfs/usr/lib/aarch64-linux-gnu/*
$ strip initramfs/usr/lib/udev/*_id


(11) Copy petitboot-related utilities
Code: Select all
$ cp initramfs/usr/local/sbin/* initramfs/usr/sbin/        # <<<----- added


3. Pack as uInitrd

(1) CPIO creation and image compression if needed
Code: Select all
$ cd initramfs
$ find . | cpio -H newc -o > ../initramfs.cpio
$ cd ..

(2) Pack as uboot mkimage
Code: Select all
$ mkimage -A arm64 -O linux -T ramdisk -C none -a 0 -e 0 -n uInitrd -d initramfs.cpio uInitrd


If needed, compress cpio image as lzma format.
This option will be a default because of the size issue
and it's compatible in boot application of u-boot.
Code: Select all
$ cat initramfs.cpio | lzma > initramfs.igz
$ mkimage -A arm64 -O linux -T ramdisk -C lzma -a 0 -e 0 -n uInitrd.igz -d initramfs.igz uInitrd.igz


Then, replace uInitrd under /media/boot/ with the new one.
Code: Select all
$ cp uInitrd /media/boot/uInitrd


If you use lzma-formatted uInitrd.igz, you should modify /media/boot/boot.ini as following.
Code: Select all
## load mmc 1:0 ${initrd_addr} uInitrd
load mmc 1:0 ${initrd_addr} uInitrd.igz


=================================================================================================
[ Step 2. Kernel Configuration ]

(updated 2018/11/09, 11:20 AM)


Here are patch files of N1 kernel defconfig.
Please find the attachments and build kernel with them again.

(1) Preparation and Download Kernel
Download kernel.
Code: Select all
$ cd /home/odroid/
$ git clone https://github.com/hardkernel/linux -b odroidn1-4.4.y
$ cd ./odroidn1-4.4.y


(2) Apply Patches
Download the attached patches and move them into your kernel path.
Then, apply patches for kernel.
Code: Select all
$ mv ~/Download/0001_n1_add_kexec.diff.zip /home/odroid/linux/
$ mv ~/Download/0002_n1_support_petitboot.diff.zip /home/odroid/linux/
$ cd /home/odroid/linux
$ unzip 0001_n1_add_kexec.diff.zip 0002_n1_support_petitboot.diff.zip
$ patch -p1 < 0001_n1_add_kexec.diff
$ patch -p1 < 0002_n1_support_petitboot.diff

(3) Build Kernel
Now let's build kernel.
Code: Select all
$ make odroidn1_defconfig
$ make Image dtbs -j5
$ cp arch/arm64/boot/Image /media/boot/Image
$ cp arch/arm64/boot/dts/rockchip/rk3399-odroidn1-linux.dtb /media/boot/rk3399-odroidn1-linux.dtb


[ Kernel Patches ]
0001_n1_add_kexec.diff
Code: Select all
From 705d73ddaf70ea7ece5584d0514067f8fd8bf8be Mon Sep 17 00:00:00 2001
From: joy <joy.cho@hardkernel.com>
Date: Thu, 29 Mar 2018 16:15:15 +0900
Subject: [PATCH] defconfig: odroidn1: activate kexec configuration

Change-Id: I5c31c90630e80a85e02b45613b41ae1164ab57a3
---

diff --git a/arch/arm64/configs/odroidn1_defconfig b/arch/arm64/configs/odroidn1_defconfig
index 89867cf..50a2f06 100644
--- a/arch/arm64/configs/odroidn1_defconfig
+++ b/arch/arm64/configs/odroidn1_defconfig
@@ -200,6 +200,7 @@
 # CONFIG_SYSTEM_DATA_VERIFICATION is not set
 CONFIG_PROFILING=y
 CONFIG_TRACEPOINTS=y
+CONFIG_KEXEC_CORE=y
 # CONFIG_KPROBES is not set
 # CONFIG_JUMP_LABEL is not set
 # CONFIG_UPROBES is not set
@@ -448,7 +449,7 @@
 # CONFIG_IDLE_PAGE_TRACKING is not set
 CONFIG_FRAME_VECTOR=y
 CONFIG_SECCOMP=y
-# CONFIG_KEXEC is not set
+CONFIG_KEXEC=y
 # CONFIG_CRASH_DUMP is not set
 # CONFIG_XEN is not set
 CONFIG_FORCE_MAX_ZONEORDER=11


0002_n1_support_petitboot.diff
Code: Select all
From 7d50a8251506a1218113d62ab6be9257a918fdf9 Mon Sep 17 00:00:00 2001
From: Joy Cho <joy.cho@hardkernel.com>
Date: Wed, 01 Aug 2018 17:02:24 +0900
Subject: [PATCH] (do NOT merge) defconfig: odroidn1: support petitboot

Change-Id: Iec4e8d65635f374a76965def342821badc652276
---

diff --git a/arch/arm64/configs/odroidn1_defconfig b/arch/arm64/configs/odroidn1_defconfig
index 50a2f06..ef57816 100644
--- a/arch/arm64/configs/odroidn1_defconfig
+++ b/arch/arm64/configs/odroidn1_defconfig
@@ -1325,50 +1325,52 @@
 # CONFIG_ATA_GENERIC is not set
 # CONFIG_PATA_LEGACY is not set
 CONFIG_MD=y
-CONFIG_BLK_DEV_MD=m
-CONFIG_MD_LINEAR=m
-CONFIG_MD_RAID0=m
-CONFIG_MD_RAID1=m
-CONFIG_MD_RAID10=m
-CONFIG_MD_RAID456=m
-CONFIG_MD_MULTIPATH=m
-CONFIG_MD_FAULTY=m
-CONFIG_BCACHE=m
+CONFIG_BLK_DEV_MD=y
+CONFIG_MD_AUTODETECT=y
+CONFIG_MD_LINEAR=y
+CONFIG_MD_RAID0=y
+CONFIG_MD_RAID1=y
+CONFIG_MD_RAID10=y
+CONFIG_MD_RAID456=y
+CONFIG_MD_MULTIPATH=y
+CONFIG_MD_FAULTY=y
+CONFIG_BCACHE=y
 # CONFIG_BCACHE_DEBUG is not set
 # CONFIG_BCACHE_CLOSURES_DEBUG is not set
 CONFIG_BLK_DEV_DM_BUILTIN=y
-CONFIG_BLK_DEV_DM=m
+CONFIG_BLK_DEV_DM=y
 CONFIG_DM_MQ_DEFAULT=y
 CONFIG_DM_DEBUG=y
-CONFIG_DM_BUFIO=m
-CONFIG_DM_BIO_PRISON=m
-CONFIG_DM_PERSISTENT_DATA=m
+CONFIG_DM_BUFIO=y
+CONFIG_DM_BIO_PRISON=y
+CONFIG_DM_PERSISTENT_DATA=y
 CONFIG_DM_DEBUG_BLOCK_STACK_TRACING=y
-CONFIG_DM_CRYPT=m
-CONFIG_DM_SNAPSHOT=m
-CONFIG_DM_THIN_PROVISIONING=m
-CONFIG_DM_CACHE=m
-CONFIG_DM_CACHE_MQ=m
-CONFIG_DM_CACHE_SMQ=m
-CONFIG_DM_CACHE_CLEANER=m
-CONFIG_DM_ERA=m
-CONFIG_DM_MIRROR=m
-CONFIG_DM_LOG_USERSPACE=m
-CONFIG_DM_RAID=m
-CONFIG_DM_ZERO=m
-CONFIG_DM_MULTIPATH=m
-CONFIG_DM_MULTIPATH_QL=m
-CONFIG_DM_MULTIPATH_ST=m
-CONFIG_DM_DELAY=m
+CONFIG_DM_CRYPT=y
+CONFIG_DM_SNAPSHOT=y
+CONFIG_DM_THIN_PROVISIONING=y
+CONFIG_DM_CACHE=y
+CONFIG_DM_CACHE_MQ=y
+CONFIG_DM_CACHE_SMQ=y
+CONFIG_DM_CACHE_CLEANER=y
+CONFIG_DM_ERA=y
+CONFIG_DM_MIRROR=y
+CONFIG_DM_LOG_USERSPACE=y
+CONFIG_DM_RAID=y
+CONFIG_DM_ZERO=y
+CONFIG_DM_MULTIPATH=y
+CONFIG_DM_MULTIPATH_QL=y
+CONFIG_DM_MULTIPATH_ST=y
+CONFIG_DM_DELAY=y
 CONFIG_DM_UEVENT=y
-CONFIG_DM_FLAKEY=m
-CONFIG_DM_VERITY=m
+CONFIG_DM_FLAKEY=y
+CONFIG_DM_VERITY=y
 CONFIG_DM_VERITY_HASH_PREFETCH_MIN_SIZE_128=y
 CONFIG_DM_VERITY_HASH_PREFETCH_MIN_SIZE=128
 CONFIG_DM_VERITY_FEC=y
-CONFIG_DM_SWITCH=m
-CONFIG_DM_LOG_WRITES=m
-CONFIG_DM_VERITY_AVB=m
+CONFIG_DM_SWITCH=y
+CONFIG_DM_LOG_WRITES=y
+CONFIG_DM_VERITY_AVB=y
+# CONFIG_DM_ANDROID_VERITY is not set
 # CONFIG_TARGET_CORE is not set
 # CONFIG_FUSION is not set
 
@@ -3656,9 +3658,9 @@
 # CONFIG_HID_KENSINGTON is not set
 CONFIG_HID_LCPOWER=m
 CONFIG_HID_LENOVO=m
-CONFIG_HID_LOGITECH=m
-CONFIG_HID_LOGITECH_DJ=m
-CONFIG_HID_LOGITECH_HIDPP=m
+CONFIG_HID_LOGITECH=y
+CONFIG_HID_LOGITECH_DJ=y
+CONFIG_HID_LOGITECH_HIDPP=y
 CONFIG_LOGITECH_FF=y
 CONFIG_LOGIRUMBLEPAD2_FF=y
 CONFIG_LOGIG940_FF=y
@@ -4818,18 +4820,18 @@
 CONFIG_JBD2=y
 # CONFIG_JBD2_DEBUG is not set
 CONFIG_FS_MBCACHE=y
-CONFIG_REISERFS_FS=m
+CONFIG_REISERFS_FS=y
 # CONFIG_REISERFS_CHECK is not set
 CONFIG_REISERFS_PROC_INFO=y
 CONFIG_REISERFS_FS_XATTR=y
 CONFIG_REISERFS_FS_POSIX_ACL=y
 CONFIG_REISERFS_FS_SECURITY=y
-CONFIG_JFS_FS=m
+CONFIG_JFS_FS=y
 CONFIG_JFS_POSIX_ACL=y
 CONFIG_JFS_SECURITY=y
 # CONFIG_JFS_DEBUG is not set
 CONFIG_JFS_STATISTICS=y
-CONFIG_XFS_FS=m
+CONFIG_XFS_FS=y
 CONFIG_XFS_QUOTA=y
 CONFIG_XFS_POSIX_ACL=y
 CONFIG_XFS_RT=y
@@ -4837,14 +4839,14 @@
 # CONFIG_XFS_DEBUG is not set
 # CONFIG_GFS2_FS is not set
 # CONFIG_OCFS2_FS is not set
-CONFIG_BTRFS_FS=m
+CONFIG_BTRFS_FS=y
 CONFIG_BTRFS_FS_POSIX_ACL=y
 # CONFIG_BTRFS_FS_CHECK_INTEGRITY is not set
 CONFIG_BTRFS_FS_RUN_SANITY_TESTS=y
 # CONFIG_BTRFS_DEBUG is not set
 CONFIG_BTRFS_ASSERT=y
 # CONFIG_NILFS2_FS is not set
-CONFIG_F2FS_FS=m
+CONFIG_F2FS_FS=y
 CONFIG_F2FS_STAT_FS=y
 CONFIG_F2FS_FS_XATTR=y
 CONFIG_F2FS_FS_POSIX_ACL=y
@@ -4857,7 +4859,7 @@
 CONFIG_FS_POSIX_ACL=y
 CONFIG_EXPORTFS=y
 CONFIG_FILE_LOCKING=y
-CONFIG_FS_ENCRYPTION=m
+CONFIG_FS_ENCRYPTION=y
 CONFIG_FSNOTIFY=y
 CONFIG_DNOTIFY=y
 CONFIG_INOTIFY_USER=y
@@ -4866,14 +4868,14 @@
 # CONFIG_QUOTA_NETLINK_INTERFACE is not set
 CONFIG_PRINT_QUOTA_WARNING=y
 # CONFIG_QUOTA_DEBUG is not set
-CONFIG_QUOTA_TREE=m
-CONFIG_QFMT_V1=m
-CONFIG_QFMT_V2=m
+CONFIG_QUOTA_TREE=y
+CONFIG_QFMT_V1=y
+CONFIG_QFMT_V2=y
 CONFIG_QUOTACTL=y
-CONFIG_AUTOFS4_FS=m
-CONFIG_FUSE_FS=m
-CONFIG_CUSE=m
-CONFIG_OVERLAY_FS=m
+CONFIG_AUTOFS4_FS=y
+CONFIG_FUSE_FS=y
+CONFIG_CUSE=y
+CONFIG_OVERLAY_FS=y
 
 #
 # Caches
@@ -4883,21 +4885,21 @@
 #
 # CD-ROM/DVD Filesystems
 #
-CONFIG_ISO9660_FS=m
+CONFIG_ISO9660_FS=y
 CONFIG_JOLIET=y
 CONFIG_ZISOFS=y
-CONFIG_UDF_FS=m
+CONFIG_UDF_FS=y
 CONFIG_UDF_NLS=y
 
 #
 # DOS/FAT/NT Filesystems
 #
-CONFIG_FAT_FS=m
-CONFIG_MSDOS_FS=m
-CONFIG_VFAT_FS=m
+CONFIG_FAT_FS=y
+CONFIG_MSDOS_FS=y
+CONFIG_VFAT_FS=y
 CONFIG_FAT_DEFAULT_CODEPAGE=936
 CONFIG_FAT_DEFAULT_IOCHARSET="utf8"
-CONFIG_NTFS_FS=m
+CONFIG_NTFS_FS=y
 # CONFIG_NTFS_DEBUG is not set
 CONFIG_NTFS_RW=y
 
@@ -4941,35 +4943,35 @@
 # CONFIG_SYSV_FS is not set
 # CONFIG_UFS_FS is not set
 CONFIG_NETWORK_FILESYSTEMS=y
-CONFIG_NFS_FS=m
-CONFIG_NFS_V2=m
-CONFIG_NFS_V3=m
+CONFIG_NFS_FS=y
+CONFIG_NFS_V2=y
+CONFIG_NFS_V3=y
 CONFIG_NFS_V3_ACL=y
-CONFIG_NFS_V4=m
+CONFIG_NFS_V4=y
 CONFIG_NFS_SWAP=y
 CONFIG_NFS_V4_1=y
 CONFIG_NFS_V4_2=y
-CONFIG_PNFS_FILE_LAYOUT=m
-CONFIG_PNFS_BLOCK=m
+CONFIG_PNFS_FILE_LAYOUT=y
+CONFIG_PNFS_BLOCK=y
 CONFIG_PNFS_FLEXFILE_LAYOUT=m
 CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN="kernel.org"
 CONFIG_NFS_V4_1_MIGRATION=y
 # CONFIG_NFS_USE_LEGACY_DNS is not set
 CONFIG_NFS_USE_KERNEL_DNS=y
-CONFIG_NFSD=m
+CONFIG_NFSD=y
 CONFIG_NFSD_V2_ACL=y
 CONFIG_NFSD_V3=y
 CONFIG_NFSD_V3_ACL=y
 CONFIG_NFSD_V4=y
 CONFIG_NFSD_PNFS=y
 CONFIG_NFSD_FAULT_INJECTION=y
-CONFIG_GRACE_PERIOD=m
-CONFIG_LOCKD=m
+CONFIG_GRACE_PERIOD=y
+CONFIG_LOCKD=y
 CONFIG_LOCKD_V4=y
-CONFIG_NFS_ACL_SUPPORT=m
+CONFIG_NFS_ACL_SUPPORT=y
 CONFIG_NFS_COMMON=y
-CONFIG_SUNRPC=m
-CONFIG_SUNRPC_GSS=m
+CONFIG_SUNRPC=y
+CONFIG_SUNRPC_GSS=y
 CONFIG_SUNRPC_BACKCHANNEL=y
 CONFIG_SUNRPC_SWAP=y
 # CONFIG_SUNRPC_DEBUG is not set
@@ -4980,54 +4982,54 @@
 # CONFIG_AFS_FS is not set
 CONFIG_NLS=y
 CONFIG_NLS_DEFAULT="utf8"
-CONFIG_NLS_CODEPAGE_437=m
-CONFIG_NLS_CODEPAGE_737=m
-CONFIG_NLS_CODEPAGE_775=m
-CONFIG_NLS_CODEPAGE_850=m
-CONFIG_NLS_CODEPAGE_852=m
-CONFIG_NLS_CODEPAGE_855=m
-CONFIG_NLS_CODEPAGE_857=m
-CONFIG_NLS_CODEPAGE_860=m
-CONFIG_NLS_CODEPAGE_861=m
-CONFIG_NLS_CODEPAGE_862=m
-CONFIG_NLS_CODEPAGE_863=m
-CONFIG_NLS_CODEPAGE_864=m
-CONFIG_NLS_CODEPAGE_865=m
-CONFIG_NLS_CODEPAGE_866=m
-CONFIG_NLS_CODEPAGE_869=m
-CONFIG_NLS_CODEPAGE_936=m
-CONFIG_NLS_CODEPAGE_950=m
-CONFIG_NLS_CODEPAGE_932=m
-CONFIG_NLS_CODEPAGE_949=m
-CONFIG_NLS_CODEPAGE_874=m
-CONFIG_NLS_ISO8859_8=m
-CONFIG_NLS_CODEPAGE_1250=m
-CONFIG_NLS_CODEPAGE_1251=m
-CONFIG_NLS_ASCII=m
-CONFIG_NLS_ISO8859_1=m
-CONFIG_NLS_ISO8859_2=m
-CONFIG_NLS_ISO8859_3=m
-CONFIG_NLS_ISO8859_4=m
-CONFIG_NLS_ISO8859_5=m
-CONFIG_NLS_ISO8859_6=m
-CONFIG_NLS_ISO8859_7=m
-CONFIG_NLS_ISO8859_9=m
-CONFIG_NLS_ISO8859_13=m
-CONFIG_NLS_ISO8859_14=m
-CONFIG_NLS_ISO8859_15=m
-CONFIG_NLS_KOI8_R=m
-CONFIG_NLS_KOI8_U=m
-CONFIG_NLS_MAC_ROMAN=m
-CONFIG_NLS_MAC_CELTIC=m
-CONFIG_NLS_MAC_CENTEURO=m
-CONFIG_NLS_MAC_CROATIAN=m
-CONFIG_NLS_MAC_CYRILLIC=m
-CONFIG_NLS_MAC_GAELIC=m
-CONFIG_NLS_MAC_GREEK=m
-CONFIG_NLS_MAC_ICELAND=m
-CONFIG_NLS_MAC_INUIT=m
-CONFIG_NLS_MAC_ROMANIAN=m
-CONFIG_NLS_MAC_TURKISH=m
+CONFIG_NLS_CODEPAGE_437=y
+CONFIG_NLS_CODEPAGE_737=y
+CONFIG_NLS_CODEPAGE_775=y
+CONFIG_NLS_CODEPAGE_850=y
+CONFIG_NLS_CODEPAGE_852=y
+CONFIG_NLS_CODEPAGE_855=y
+CONFIG_NLS_CODEPAGE_857=y
+CONFIG_NLS_CODEPAGE_860=y
+CONFIG_NLS_CODEPAGE_861=y
+CONFIG_NLS_CODEPAGE_862=y
+CONFIG_NLS_CODEPAGE_863=y
+CONFIG_NLS_CODEPAGE_864=y
+CONFIG_NLS_CODEPAGE_865=y
+CONFIG_NLS_CODEPAGE_866=y
+CONFIG_NLS_CODEPAGE_869=y
+CONFIG_NLS_CODEPAGE_936=y
+CONFIG_NLS_CODEPAGE_950=y
+CONFIG_NLS_CODEPAGE_932=y
+CONFIG_NLS_CODEPAGE_949=y
+CONFIG_NLS_CODEPAGE_874=y
+CONFIG_NLS_ISO8859_8=y
+CONFIG_NLS_CODEPAGE_1250=y
+CONFIG_NLS_CODEPAGE_1251=y
+CONFIG_NLS_ASCII=y
+CONFIG_NLS_ISO8859_1=y
+CONFIG_NLS_ISO8859_2=y
+CONFIG_NLS_ISO8859_3=y
+CONFIG_NLS_ISO8859_4=y
+CONFIG_NLS_ISO8859_5=y
+CONFIG_NLS_ISO8859_6=y
+CONFIG_NLS_ISO8859_7=y
+CONFIG_NLS_ISO8859_9=y
+CONFIG_NLS_ISO8859_13=y
+CONFIG_NLS_ISO8859_14=y
+CONFIG_NLS_ISO8859_15=y
+CONFIG_NLS_KOI8_R=y
+CONFIG_NLS_KOI8_U=y
+CONFIG_NLS_MAC_ROMAN=y
+CONFIG_NLS_MAC_CELTIC=y
+CONFIG_NLS_MAC_CENTEURO=y
+CONFIG_NLS_MAC_CROATIAN=y
+CONFIG_NLS_MAC_CYRILLIC=y
+CONFIG_NLS_MAC_GAELIC=y
+CONFIG_NLS_MAC_GREEK=y
+CONFIG_NLS_MAC_ICELAND=y
+CONFIG_NLS_MAC_INUIT=y
+CONFIG_NLS_MAC_ROMANIAN=y
+CONFIG_NLS_MAC_TURKISH=y
 CONFIG_NLS_UTF8=y
 # CONFIG_DLM is not set
 # CONFIG_VIRTUALIZATION is not set
@@ -5227,7 +5229,7 @@
 # CONFIG_PERSISTENT_KEYRINGS is not set
 # CONFIG_BIG_KEYS is not set
 # CONFIG_TRUSTED_KEYS is not set
-CONFIG_ENCRYPTED_KEYS=m
+CONFIG_ENCRYPTED_KEYS=y
 # CONFIG_SECURITY_DMESG_RESTRICT is not set
 # CONFIG_SECURITY_PERF_EVENTS_RESTRICT is not set
 # CONFIG_SECURITY is not set
@@ -5238,12 +5240,12 @@
 # CONFIG_TEE_SUPPORT is not set
 CONFIG_DEFAULT_SECURITY_DAC=y
 CONFIG_DEFAULT_SECURITY=""
-CONFIG_XOR_BLOCKS=m
-CONFIG_ASYNC_CORE=m
-CONFIG_ASYNC_MEMCPY=m
-CONFIG_ASYNC_XOR=m
-CONFIG_ASYNC_PQ=m
-CONFIG_ASYNC_RAID6_RECOV=m
+CONFIG_XOR_BLOCKS=y
+CONFIG_ASYNC_CORE=y
+CONFIG_ASYNC_MEMCPY=y
+CONFIG_ASYNC_XOR=y
+CONFIG_ASYNC_PQ=y
+CONFIG_ASYNC_RAID6_RECOV=y
 CONFIG_CRYPTO=y
 
 #
@@ -5291,14 +5293,14 @@
 #
 # Block modes
 #
-CONFIG_CRYPTO_CBC=m
+CONFIG_CRYPTO_CBC=y
 # CONFIG_CRYPTO_HEH is not set
 CONFIG_CRYPTO_CTR=y
-CONFIG_CRYPTO_CTS=m
+CONFIG_CRYPTO_CTS=y
 CONFIG_CRYPTO_ECB=y
 # CONFIG_CRYPTO_LRW is not set
 # CONFIG_CRYPTO_PCBC is not set
-CONFIG_CRYPTO_XTS=m
+CONFIG_CRYPTO_XTS=y
 # CONFIG_CRYPTO_KEYWRAP is not set
 
 #
@@ -5313,7 +5315,7 @@
 # Digest
 #
 CONFIG_CRYPTO_CRC32C=y
-CONFIG_CRYPTO_CRC32=m
+CONFIG_CRYPTO_CRC32=y
 CONFIG_CRYPTO_CRCT10DIF=y
 CONFIG_CRYPTO_GHASH=y
 # CONFIG_CRYPTO_POLY1305 is not set
@@ -5407,7 +5409,7 @@
 #
 # Library routines
 #
-CONFIG_RAID6_PQ=m
+CONFIG_RAID6_PQ=y
 CONFIG_BITREVERSE=y
 CONFIG_HAVE_ARCH_BITREVERSE=y
 CONFIG_RATIONAL=y
@@ -5433,7 +5435,7 @@
 CONFIG_AUDIT_ARCH_COMPAT_GENERIC=y
 # CONFIG_RANDOM32_SELFTEST is not set
 CONFIG_ZLIB_INFLATE=y
-CONFIG_ZLIB_DEFLATE=m
+CONFIG_ZLIB_DEFLATE=y
 CONFIG_LZO_COMPRESS=y
 CONFIG_LZO_DECOMPRESS=y
 CONFIG_LZ4_DECOMPRESS=y
@@ -5453,7 +5455,7 @@
 CONFIG_DECOMPRESS_LZO=y
 CONFIG_DECOMPRESS_LZ4=y
 CONFIG_GENERIC_ALLOCATOR=y
-CONFIG_REED_SOLOMON=m
+CONFIG_REED_SOLOMON=y
 CONFIG_REED_SOLOMON_DEC8=y
 CONFIG_TEXTSEARCH=y
 CONFIG_TEXTSEARCH_KMP=m


Once basic operation is completed without issues, to reduce kernel and ramdisk size, many part of defconfigs will be disabled.
But now let's include all default configs based on the latest release version.

=================================================================================================
[ Step 3. Booting from 1st storage and Load petitboot application ]
First, copy updated Image and uInitrd images to your card.
And you need to adjust some part of boot.ini.

1. bootargs
Add console=tty0 in bootargs.
Code: Select all
setenv bootrootfs "swiotlb=1 console=ttyFIQ0,115200n8 root=UUID=e139ce78-9841-40fe-8823-96a304a09859 rootwait rw"


2. load images
Code: Select all
load mmc 1:0 ${kernel_addr} Image
load mmc 1:0 ${initrd_addr} uInitrd
# or lzma format is available -->  load mmc 1:0 ${initrd_addr} uInitrd.igz
load mmc 1:0 ${fdt_addr} rk3399-odroidn1-linux.dtb

booti ${kernel_addr} ${initrd_addr} ${fdt_loadaddr}


Now power-on your N1 and you will get petitboot menus from your monitor
and you can select menus and change/add system configurations for next booting using keyboards.
=================================================================================================
[ Step 4. Add a boot option and Jump to 2nd kernel ]
Using a menu you can find attached storage and make a boot option.
petitboot_1_mainmenu.png
petitboot_1_mainmenu.png (7.76 KiB) Viewed 957 times

Enter 'n'. then specify parameters and enter "OK".
For example, I made one vfat and one ext4 for rootfs on my USB stick
and copy another customized Kernel Image (ex:android) and uInitrd in vfat
and make a new rootfs in USB ext4. (in my case, I wrote a ubuntu minimal rootfs for test.)
so I got the display as following.
I specified the parameters.
    Device : sda1
    Kernel : Image
    Initrd : uInitrd
    Boot arguments : swiotlb=1 console=ttyFIQ0,115200n8 console=tty0 root=/dev/sda2 rootwait rw
Now I have "User Item 1" at the 1st line of Main Menu and you can jump to 2nd kernel and rootfs via the menu.

Done!!! I got Ubuntu minimal console.
petitboot_8_addbootopt.png
petitboot_8_addbootopt.png (8.9 KiB) Viewed 1203 times


Or in /etc/kboot.conf, defalut parameters can be specified.
Code: Select all
USB='sda1:/Image initrd=sda1:/uInitrd swiotlb=1 console=ttyFIQ0,115200n8 root=/dev/sda2 rootwait rw'
SATA='sdb1:/Image initrd=sdb1:/uInitrd swiotlb=1 console=ttyFIQ0,115200n8 root=/dev/sdb2 rootwait rw'

The operation is a same sequence using kexec commands.
Code: Select all
$ kexec -l /mnt/sda1/Image --initrd=/mnt/sda1/uInitrd --append="swiotlb=1 console=ttyFIQ0,115200n8 root=/dev/sda2 rootfstype=ext4 rootwait rw"
$ kexec -e

Code: Select all
$ kexec -l /mnt/sdb1/Image --initrd=/mnt/sdb1/uInitrd --append="swiotlb=1 console=ttyFIQ0,115200n8 root=/dev/sdb2 rootfstype=ext4 rootwait rw"
$ kexec -e


=================================================================================================
[ Issues ]

1. Issue 1 - Very late jump time to 2nd booting
Now we can jump to next booting to 2nd kernel and root file system from 2nd storage like usb or sata.
But the problem is I have to wait to load 2nd kernel.
Currently, it takes about 5~10 seconds till I can get 2nd kernel booting log. :(
I couldn't how I can figure out to optimize the waiting time.

2. Issue 2 - 2nd DTB load
I want to load different dts options flexibly but, it seems dtb option of petitboot and kexec doesn't work as I expected.

3. Issues 3 - Size option with small size SPI NAND/NOR
About this issue, I've tried to remove redundant kernel features and ramdisk utility/library
and I think it may be possible to fit in 8MB SPI storage.
=================================================================================================

I look forward to getting solutions
and any suggestion and advises are welcomed.
Attachments
0002_n1_support_petitboot.diff.zip
(2.92 KiB) Downloaded 15 times
0001_n1_add_kexec.diff.zip
(691 Bytes) Downloaded 14 times
Last edited by joy on Fri Nov 09, 2018 11:17 am, edited 37 times in total.
joy
 
Posts: 571
Joined: Fri Oct 02, 2015 1:44 pm
languages_spoken: english
ODROIDs: ODROID-C1+, XU4, X

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby mad_ady » Sat Nov 03, 2018 2:38 pm

Wow, it's such a joy (haha) to hear that you're still tinkering with the N1!
I may try to go over your instructions when I get some free time, though I'm a bit swamped at the moment.
Have you tried to boot android from petitboot? Is the menu output available on hdmi/serial/both?

Great work - I hope your experiments can be applied to N2

Edit: Isn't it Saturday in your timezone? Are you working overtime or is it just a personal project?
User avatar
mad_ady
 
Posts: 4711
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby phaseshifter » Sat Nov 03, 2018 10:03 pm

Hmm ok well i thought this project was pretty much over...
i`ll try setup my N-1 and spi board and see what i can do with it ..although my code work is not any measure at all as others here.....but i will try.

i dont think i`m brilliant or that exp when it comes to others here but however...
Build It And They Will Come...Be Bold And Mighty Forces Will Come To Your Aid..!!!
phaseshifter
 
Posts: 2970
Joined: Fri May 08, 2015 9:12 am
languages_spoken: english
ODROIDs: N-1..c1+ ..c-2..xu3 lite,xu4...u-3..
u-2...other odroid acc`s as well

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby mad_ady » Sat Nov 03, 2018 10:16 pm

You don't need the spi chip for this (at this stage yet).
User avatar
mad_ady
 
Posts: 4711
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby phaseshifter » Sat Nov 03, 2018 11:27 pm

@mad_addy thnks for that...
i only browsed throug it..
i thought it was just using the petitboot program.
.but as i said i browsed over it..

Hmm spent a few hours with the above...could not get most of the listed posts to make correctly..even though i maybe missing some required packages that need to be installed...
i did install many as i went through the posts/pages..finding missing packages as i went along.. but never got past the first few posts/pages etc..etc.. not exp enough but gave it a try...most build`s/makes threw errors..

i`ll wait for furter peop`s to see what develops
Build It And They Will Come...Be Bold And Mighty Forces Will Come To Your Aid..!!!
phaseshifter
 
Posts: 2970
Joined: Fri May 08, 2015 9:12 am
languages_spoken: english
ODROIDs: N-1..c1+ ..c-2..xu3 lite,xu4...u-3..
u-2...other odroid acc`s as well

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby joy » Mon Nov 05, 2018 8:36 am

mad_ady wrote:Have you tried to boot android from petitboot?

Hi mad_ady,
Thank you for the idea.
Actually not yet, but the item is in my todo list.
I will try it.

mad_ady wrote:Is the menu output available on hdmi/serial/both?

For single output of hdmi and serial, OK.
Code: Select all
serial -> console=ttyFIQ0,115200n8
hdmi -> console=tty0

but it seems it's not possible to get controls from both of serial and display.

And actually, this item is not only for N1.
Once the whole logic with petitboot, I think it can be used for C2, XU4 or the next ODROID model
and I think the next step using SPI flash must not be complicated to be implemented.
And if we see that it's beneficial, SPI flash may be considered for next model, I think.
Last edited by joy on Mon Nov 05, 2018 9:58 am, edited 1 time in total.
joy
 
Posts: 571
Joined: Fri Oct 02, 2015 1:44 pm
languages_spoken: english
ODROIDs: ODROID-C1+, XU4, X

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby joy » Mon Nov 05, 2018 8:52 am

phaseshifter wrote:Hmm spent a few hours with the above...could not get most of the listed posts to make correctly..even though i maybe missing some required packages that need to be installed...
i did install many as i went through the posts/pages..finding missing packages as i went along.. but never got past the first few posts/pages etc..etc.. not exp enough but gave it a try...most build`s/makes threw errors..


I will check again if any installation fail comes during uInitrd setup from the pure N1 debian release image.
If needed, I will modify/update the guide soon.
And you can use the sample uInitrd file to check the whole logic without ramdisk generation process.

(updated)
I found some packages installation to fix dependencies like docbook* are missing.
I will update the guide soon then share the status here again.
Very sorry for making inconvenience.
Last edited by joy on Tue Nov 06, 2018 8:39 am, edited 2 times in total.
joy
 
Posts: 571
Joined: Fri Oct 02, 2015 1:44 pm
languages_spoken: english
ODROIDs: ODROID-C1+, XU4, X

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby elatllat » Mon Nov 05, 2018 6:53 pm

joy wrote:...SPI flash must not be complicated to be implemented.
And if we see that it's beneficial, SPI flash may be considered for next model, I think.


Just my 2 cents but SPI flash seems like a benefitless complication.
elatllat
 
Posts: 1066
Joined: Tue Sep 01, 2015 8:54 am
languages_spoken: english
ODROIDs: XU4, N1

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby mad_ady » Mon Nov 05, 2018 7:31 pm

My guess is that it would be worth it as an addon board that you can easily plug in if you need disk-less boot for large server farms.
User avatar
mad_ady
 
Posts: 4711
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby elatllat » Mon Nov 05, 2018 7:46 pm

With spi flash one can boot without sdcard flash.
With sdcard flash one can boot without spi flash.
elatllat
 
Posts: 1066
Joined: Tue Sep 01, 2015 8:54 am
languages_spoken: english
ODROIDs: XU4, N1

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby phaseshifter » Tue Nov 06, 2018 12:34 am

Well i`m all for the idea in general being it able to be used with other "odroid" model`s

however as i go through your first posting info page as it will..i find my self quite out of my depth....

when i used petitboot and the spi card addon all we did was flash the card but as yet we failed to to so ...in completion
however i never had to build petitboot all i had to do was install it..maybe that was just the extent of it and needed further configuring..??..i dont know

furthermore your "said " project has me quite interested...

through failed make`s/builds it threw errors that i dont know how to fix..i looked at what the errors threw and browsed them for answers ..i did find some and applied them..
allowing me to progress..also i found that the errors often through what packages needed to be installed..i progressed..

i firstly browsed the veiw topics and looked at what packages i could see that were being installed ..so i did that first..

as you mentioned "docbook"..hmmm cannot remember if i hd installed that.. i spent like 6 hours with it and only got through steps one to three i think ..it was a long night..i work mostly at night dont worry about that.. peace and quite round here..lol..lol.

but it was enjoyable i hope to progress further in the future..i will endeavour to keep at it..

although i am not the most exp code builder.. but i try.. sorry if my lack in this is any annoyance..if so pls tell me and i will quit the subject...
Build It And They Will Come...Be Bold And Mighty Forces Will Come To Your Aid..!!!
phaseshifter
 
Posts: 2970
Joined: Fri May 08, 2015 9:12 am
languages_spoken: english
ODROIDs: N-1..c1+ ..c-2..xu3 lite,xu4...u-3..
u-2...other odroid acc`s as well

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby rooted » Tue Nov 06, 2018 4:18 am

Trying to get this to work and posting about it is no problem phaseshifter, it's what the forum is here for mate :)
User avatar
rooted
 
Posts: 5681
Joined: Fri Dec 19, 2014 9:12 am
Location: Gulf of Mexico, US
languages_spoken: english
ODROIDs: C1, C1+, C2
XU3 Lite, XU4
N1
VU7+
HiFi Shield 2
Smart Power (original)

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby umiddelb » Tue Nov 06, 2018 6:59 am

mad_ady wrote:My guess is that it would be worth it as an addon board that you can easily plug in if you need disk-less boot for large server farms.

Both storage options have be managed. But if you are heading for automation you probably don't want a boot menue.

You can of cause put a 'thin' firmware on your sd card, which fetches all subsequent payload via tftp from a network server (instead of loading it from spi) and you're done.
umiddelb
 
Posts: 439
Joined: Thu Jan 29, 2015 6:42 am
languages_spoken: English, German
ODROIDs: ODROID-C1, ODROID-XU4, ODROID-C2

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby joy » Tue Nov 06, 2018 8:39 am

joy wrote:
phaseshifter wrote:Hmm spent a few hours with the above...could not get most of the listed posts to make correctly..even though i maybe missing some required packages that need to be installed...
i did install many as i went through the posts/pages..finding missing packages as i went along.. but never got past the first few posts/pages etc..etc.. not exp enough but gave it a try...most build`s/makes threw errors..


I will check again if any installation fail comes during uInitrd setup from the pure N1 debian release image.
If needed, I will modify/update the guide soon.
And you can use the sample uInitrd file to check the whole logic without ramdisk generation process.

(updated)
I found some packages installation to fix dependencies like docbook* are missing.
I will update the guide soon then share the status here again.
Very sorry for making inconvenience.

Hi.
I've updated some parts of uInitrd generation guide.
Installation preparation process to build systemd and others were missing. :o
Also I found some typo errors.
phaseshifter must have encountered a lot of build errors. :(
Sorry again.

And I will try to make auto-installation script this week.
The manual installation process by typing must be irritated and a big burden for busy friends here. :)
Please let me work it for a couple of days more.
joy
 
Posts: 571
Joined: Fri Oct 02, 2015 1:44 pm
languages_spoken: english
ODROIDs: ODROID-C1+, XU4, X

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby joy » Tue Nov 06, 2018 10:18 am

phaseshifter wrote:when i used petitboot and the spi card addon all we did was flash the card but as yet we failed to to so ...in completion
however i never had to build petitboot all i had to do was install it..maybe that was just the extent of it and needed further configuring..??..i dont know

Yes, your opinion is right and I thought as you do.
But the more I go forward, I realized a tiny initrd that is dedicated to bios with petitboot must be needed.
    1. must be small size to built in SPI flash : includes very mandatory packages and libraries to run petitboot and related utils
    2. optimize petitboot menus and options for needs targeting to ODROID product
    3. remove unusable features : ex) network (just consideration, it's a big part of kernel image)
Actually we're considering a small SPI flash, 8MB to build-in,
and in this flash, boot loaders, env, dtb, kernel and ramdisk must be contained.

phaseshifter wrote:through failed make`s/builds it threw errors that i dont know how to fix..i looked at what the errors threw and browsed them for answers ..i did find some and applied them..
allowing me to progress..also i found that the errors often through what packages needed to be installed..i progressed..

i firstly browsed the veiw topics and looked at what packages i could see that were being installed ..so i did that first..

as you mentioned "docbook"..hmmm cannot remember if i hd installed that.. i spent like 6 hours with it and only got through steps one to three i think ..it was a long night..i work mostly at night dont worry about that.. peace and quite round here..lol..lol.

but it was enjoyable i hope to progress further in the future..i will endeavour to keep at it..

although i am not the most exp code builder.. but i try.. sorry if my lack in this is any annoyance..if so pls tell me and i will quit the subject...


I've updated the guide. It was my mistake that missed a part of installation progress.
When I made the uInitrd at the fist time with Google God, I went almost crazy, :o and now I feel bad because I made you like me. :(
Now I'm trying the progress on another model besides N1 so I was confused.

I'm not sure there is still any missed point in the instructions.
So if you encountered any issue during installation or running, please let me know. I don't want you to waste your time.
I will also try to make auto-installation script to build uInitrd.

And I want users to give us if this approach is the best one.
So if you're available, please check the whole flow I suggested and feel free to tell your opinions.
It will be very helpful to next model design (hw/sw all).

I made a reference uInitrd and you can find the image in above guide.
The reason why I made this thread is to discuss the whole working flow with petitboot and get some solutions to fix the following issues.
    1. Issue 1 - Very late jump time to 2nd booting
    2. Issue 2 - 2nd DTB load
So if you want, please check the whole flow of bios with petitboot.
Making uInitrd is not an important part, I think.

Any questions are very welcomed. :)
joy
 
Posts: 571
Joined: Fri Oct 02, 2015 1:44 pm
languages_spoken: english
ODROIDs: ODROID-C1+, XU4, X

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby mad_ady » Tue Nov 06, 2018 2:48 pm

Becoming crazy is always part of the learning process :)
User avatar
mad_ady
 
Posts: 4711
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby joy » Tue Nov 06, 2018 3:39 pm

mad_ady wrote:Becoming crazy is always part of the learning process :)

Yes!!! I totally agree with you! :D
joy
 
Posts: 571
Joined: Fri Oct 02, 2015 1:44 pm
languages_spoken: english
ODROIDs: ODROID-C1+, XU4, X

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby joy » Tue Nov 06, 2018 4:11 pm

Hi all.
I've updated instructions and confirmed it by doing A to Z again with empty card and initial debian image.
So if there is anyone who wants trying it, please try it now.
joy
 
Posts: 571
Joined: Fri Oct 02, 2015 1:44 pm
languages_spoken: english
ODROIDs: ODROID-C1+, XU4, X

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby elatllat » Tue Nov 06, 2018 11:03 pm

joy wrote:SPI flash, 8MB

DD-WRT and openwrt seem to think 8 MB is enough so you might look at what they do.

I think strip is a no-op if you just disable debug in the config.

a start on a scripted version attempting to follow best practices;
[EDIT]See later post for github link[/EDIT]
Last edited by elatllat on Thu Nov 08, 2018 8:27 am, edited 1 time in total.
elatllat
 
Posts: 1066
Joined: Tue Sep 01, 2015 8:54 am
languages_spoken: english
ODROIDs: XU4, N1

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby joy » Wed Nov 07, 2018 9:56 am

elatllat wrote:
joy wrote:SPI flash, 8MB

DD-WRT and openwrt seem to think 8 MB is enough so you might look at what they do.

I think strip is a no-op if you just disable debug in the config.

OK. I will try.

And one more problem is kernel size.
But, as I've tried, it's possible to reduce kernel image under 3.5MB so far, so 8MB is enough.
elatllat wrote:a start on a scripted version attempting to follow best practices;
Code: Select all
#!/bin/bash

set -e

# prep
C=$(id | grep -c "(root)" || true)
if [ "$C" -gt 0 ] ; then
    echo "please re-run as root" >&2
    exit 1
fi
C=$(apt-get --just-print upgrade | grep -cP "^Inst " || true)
if [ "$C" -gt 0 ] ; then
    apt-get update -y
    apt-get upgrade -y
    apt-get dist-upgrade -y
    echo "Please re-run after reboot."
    echo "Reboot now? [y|n]"
    read -r YN
    if [ "$YN" == "y" ] ; then
        reboot
    else
        exit 1
    fi
fi
apt-get install -y \
    git autoconf automake autopoint libtool pkg-config \
    libudev-dev libdevmapper-dev flex bison gettext \
    intltool libgcrypt20-dev \
    gperf libcap-dev libblkid-dev libmount-dev \
    xsltproc docbook-xsl docbook-xml python-lxml \
    libncurses5-dev libncursesw5-dev \
    libdw-dev libgpgme-dev
cd /home/odroid
mkdir -p ramdisk_petitboot
cd ramdisk_petitboot

if [ ! -d systemd ] ; then
    git clone --depth 1 git://anongit.freedesktop.org/systemd/systemd
    (
    cd systemd
        ./autogen.sh
        mkdir build
        (
            cd build
            ../configure --prefix=/usr --enable-blkid --disable-seccomp --disable-libcurl --disable-pam --disable-kmod
            make -j "$(nproc)"
        )
    )
fi

if [ ! -d kexec-tools ] ; then
    git clone --depth 1 git://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git
    (
        cd kexec-tools
        ./bootstrap
        ./configure --prefix=/usr
        make -j "$(nproc)"
    )
fi

if [ ! -d libtwin ] ; then
     git clone --depth 1 git://git.kernel.org/pub/scm/linux/kernel/git/geoff/libtwin.git
     (
         cd libtwin
         ./autogen.sh
         make
         make install
     )
fi


if [ ! -d petitboot ] ; then
    git clone --depth 1 -b petitboot-1.6.x https://github.com/open-power/petitboot.git
    {
        cd petitboot
        ./bootstrap
        ./configure --with-twin-x11=no --with-twin-fbdev=no --with-signed-boot=no --disable-nls
        make -j "$(nproc)"
    }
fi

if [ ! -d busybox ] ; then
    git clone  --depth 1 git://git.busybox.net/busybox
    (
        cd busybox
        make defconfig
    )
    LDFLAGS=--static make -j "$(nproc)"
fi

if [ ! -d initramfs ] ; then
    mkdir -p initramfs/{\
bin,\
sbin,\
etc,\
lib/aarch64-linux-gnu,\
proc,\
sys,\
newroot,\
usr/bin,\
usr/sbin,\
usr/lib/aarch64-linux-gnu,\
usr/lib/udev/rules.d,\
usr/share/udhcpc,\
var/log/petitboot,run,\
run/udev,\
tmp}
    touch initramfs/etc/mdev.conf
    cp -Rp /lib/terminfo initramfs/lib/
    cp -Rp busybox/busybox initramfs/bin/
    ln -s busybox initramfs/bin/sh
    cp -L /lib/aarch64-linux-gnu/{\
libc.so.*,\
libm.so.*,\
libdl.so.*,\
librt.so.*,\
libacl.so.*,\
libcap.so.*,\
libattr.so.*,\
libpthread.so.*,\
libncurses.so.*,\
libncursesw.so.*,\
libtinfo.so.*,\
libpcre.so.*,\
libresolv.so.*,\
libselinux.so.*,\
libreadline.so.*,\
libgcc_s.so.*,\
libblkid.so.*,\
libkmod.so.*,\
libuuid.so.*,\
libusb-1.0.so.*,\
libdevmapper.so.*,\
libz.so.*,\
liblzma.so.*,\
libbz2.so.*,\
libgpg-error.so.*,\
libnss_files.so.*} initramfs/lib/aarch64-linux-gnu/
    cp -L /lib/ld-linux-aarch64.so.* initramfs/lib/
    cp -L /usr/lib/aarch64-linux-gnu/{\
libform.so.*,\
libformw.so.*,\
libmenu.so.*,\
libmenuw.so.*,\
libelf.so.*,\
libdw.so.*,\
libgpgme.so.*,\
libassuan.so.*} initramfs/usr/lib/aarch64-linux-gnu/
    cp -Rp /usr/bin/gpg initramfs/usr/bin/
    cp systemd/build/.libs/libudev.so.* initramfs/lib/aarch64-linux-gnu/
    cp -Rp systemd/build/{systemd-udevd,udevadm} initramfs/sbin/
    cp -Rp systemd/build/*_id initramfs/usr/lib/udev/
    cp -Rp kexec-tools/build/sbin/kexec initramfs/sbin/
    cp -Rp systemd/{rules/*,build/rules/*} initramfs/usr/lib/udev/rules.d/
    rm -f initramfs/usr/lib/udev/rules.d/*-drivers.rules
    cp -Rp busybox/busybox/examples/udhcp/simple.script initramfs/usr/share/udhcpc/simple.script
    chmod 755 initramfs/usr/share/udhcpc/simple.script
    sed -i '/should be called from udhcpc/d' initramfs/usr/share/udhcpc/simple.script
    cat << EOF > initramfs/usr/share/udhcpc/default.script
#!/bin/sh

/usr/share/udhcpc/simple.script "\$@"
/usr/sbin/pb-udhcpc "\$@"
EOF
    chmod 755 initramfs/usr/share/udhcpc/default.script
    cat << EOF > initramfs/etc/nsswitch.conf
passwd:                files
group:                files
shadow:                files
hosts:                files
networks:        files
protocols:        files
services:        files
ethers:                files
rpc:                files
netgroup:        files
EOF
    cat << EOF > initramfs/etc/group
root:x:0:
daemon:x:1:
tty:x:5:
disk:x:6:
lp:x:7:
kmem:x:15:
dialout:x:20:
cdrom:x:24:
tape:x:26:
audio:x:29:
video:x:44:
input:x:122:
EOF
    cat << EOF > initramfs/init
#!/bin/sh

/bin/busybox --install -s

CURRENT_TIMESTAMP=\$(date '+%s')
if [ \$CURRENT_TIMESTAMP -lt \$(date '+%s') ]; then
        date -s "@\$(date '+%s')"
fi

mount -t proc proc /proc
mount -t sysfs sysfs /sys
mount -t devtmpfs none /dev
 
echo 0 > /proc/sys/kernel/printk
clear
 
systemd-udevd &
udevadm hwdb --update
udevadm trigger

pb-discover &
petitboot-nc
 
if [ -e /etc/pb-lockdown ] ; then
        echo "Failed to launch petitboot, rebooting!"
        echo 1 > /proc/sys/kernel/sysrq
        echo b > /proc/sysrq-trigger
else
        echo "Failed to launch petitboot, dropping to a shell"
        exec sh
fi
EOF
    chmod +x initramfs/init
   
fi

C=$(find initramfs/usr/sbin/ -type f | grep -c petitboot || true)
if [ "$C" -lt 1 ] ; then
    (
        cd petitboot
        make DESTDIR="$(realpath ../../initramfs/)" install
    )
    cp initramfs/usr/local/sbin/* initramfs/usr/sbin/
    strip initramfs/{sbin/*,usr/sbin/*,lib/aarch64-linux-gnu/*,usr/lib/aarch64-linux-gnu/*,usr/lib/udev/*_id}
fi

if [ ! -f initramfs.igz ] ; then
    (
        cd initramfs
        find . | cpio -H newc -o | lzma > ../initramfs.igz
    )
    mkimage -A arm64 -O linux -T ramdisk -C lzma -a 0 -e 0 -n uInitrd.igz -d initramfs.igz uInitrd.igz
fi

echo "Everything it OK."

Wow!!! Cool!!! :o
I will try it in a couple of hours.
joy
 
Posts: 571
Joined: Fri Oct 02, 2015 1:44 pm
languages_spoken: english
ODROIDs: ODROID-C1+, XU4, X

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby joy » Wed Nov 07, 2018 3:00 pm

joy wrote:
elatllat wrote:a start on a scripted version attempting to follow best practices;
Code: Select all
#!/bin/bash

set -e

# prep
C=$(id | grep -c "(root)" || true)
if [ "$C" -gt 0 ] ; then
    echo "please re-run as root" >&2
    exit 1
fi
C=$(apt-get --just-print upgrade | grep -cP "^Inst " || true)
if [ "$C" -gt 0 ] ; then
    apt-get update -y
    apt-get upgrade -y
    apt-get dist-upgrade -y
    echo "Please re-run after reboot."
    echo "Reboot now? [y|n]"
    read -r YN
    if [ "$YN" == "y" ] ; then
        reboot
    else
        exit 1
    fi
fi
apt-get install -y \
    git autoconf automake autopoint libtool pkg-config \
    libudev-dev libdevmapper-dev flex bison gettext \
    intltool libgcrypt20-dev \
    gperf libcap-dev libblkid-dev libmount-dev \
    xsltproc docbook-xsl docbook-xml python-lxml \
    libncurses5-dev libncursesw5-dev \
    libdw-dev libgpgme-dev
cd /home/odroid
mkdir -p ramdisk_petitboot
cd ramdisk_petitboot

if [ ! -d systemd ] ; then
    git clone --depth 1 git://anongit.freedesktop.org/systemd/systemd
    (
    cd systemd
        ./autogen.sh
        mkdir build
        (
            cd build
            ../configure --prefix=/usr --enable-blkid --disable-seccomp --disable-libcurl --disable-pam --disable-kmod
            make -j "$(nproc)"
        )
    )
fi

if [ ! -d kexec-tools ] ; then
    git clone --depth 1 git://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git
    (
        cd kexec-tools
        ./bootstrap
        ./configure --prefix=/usr
        make -j "$(nproc)"
    )
fi

if [ ! -d libtwin ] ; then
     git clone --depth 1 git://git.kernel.org/pub/scm/linux/kernel/git/geoff/libtwin.git
     (
         cd libtwin
         ./autogen.sh
         make
         make install
     )
fi


if [ ! -d petitboot ] ; then
    git clone --depth 1 -b petitboot-1.6.x https://github.com/open-power/petitboot.git
    {
        cd petitboot
        ./bootstrap
        ./configure --with-twin-x11=no --with-twin-fbdev=no --with-signed-boot=no --disable-nls
        make -j "$(nproc)"
    }
fi

if [ ! -d busybox ] ; then
    git clone  --depth 1 git://git.busybox.net/busybox
    (
        cd busybox
        make defconfig
    )
    LDFLAGS=--static make -j "$(nproc)"
fi

if [ ! -d initramfs ] ; then
    mkdir -p initramfs/{\
bin,\
sbin,\
etc,\
lib/aarch64-linux-gnu,\
proc,\
sys,\
newroot,\
usr/bin,\
usr/sbin,\
usr/lib/aarch64-linux-gnu,\
usr/lib/udev/rules.d,\
usr/share/udhcpc,\
var/log/petitboot,run,\
run/udev,\
tmp}
    touch initramfs/etc/mdev.conf
    cp -Rp /lib/terminfo initramfs/lib/
    cp -Rp busybox/busybox initramfs/bin/
    ln -s busybox initramfs/bin/sh
    cp -L /lib/aarch64-linux-gnu/{\
libc.so.*,\
libm.so.*,\
libdl.so.*,\
librt.so.*,\
libacl.so.*,\
libcap.so.*,\
libattr.so.*,\
libpthread.so.*,\
libncurses.so.*,\
libncursesw.so.*,\
libtinfo.so.*,\
libpcre.so.*,\
libresolv.so.*,\
libselinux.so.*,\
libreadline.so.*,\
libgcc_s.so.*,\
libblkid.so.*,\
libkmod.so.*,\
libuuid.so.*,\
libusb-1.0.so.*,\
libdevmapper.so.*,\
libz.so.*,\
liblzma.so.*,\
libbz2.so.*,\
libgpg-error.so.*,\
libnss_files.so.*} initramfs/lib/aarch64-linux-gnu/
    cp -L /lib/ld-linux-aarch64.so.* initramfs/lib/
    cp -L /usr/lib/aarch64-linux-gnu/{\
libform.so.*,\
libformw.so.*,\
libmenu.so.*,\
libmenuw.so.*,\
libelf.so.*,\
libdw.so.*,\
libgpgme.so.*,\
libassuan.so.*} initramfs/usr/lib/aarch64-linux-gnu/
    cp -Rp /usr/bin/gpg initramfs/usr/bin/
    cp systemd/build/.libs/libudev.so.* initramfs/lib/aarch64-linux-gnu/
    cp -Rp systemd/build/{systemd-udevd,udevadm} initramfs/sbin/
    cp -Rp systemd/build/*_id initramfs/usr/lib/udev/
    cp -Rp kexec-tools/build/sbin/kexec initramfs/sbin/
    cp -Rp systemd/{rules/*,build/rules/*} initramfs/usr/lib/udev/rules.d/
    rm -f initramfs/usr/lib/udev/rules.d/*-drivers.rules
    cp -Rp busybox/busybox/examples/udhcp/simple.script initramfs/usr/share/udhcpc/simple.script
    chmod 755 initramfs/usr/share/udhcpc/simple.script
    sed -i '/should be called from udhcpc/d' initramfs/usr/share/udhcpc/simple.script
    cat << EOF > initramfs/usr/share/udhcpc/default.script
#!/bin/sh

/usr/share/udhcpc/simple.script "\$@"
/usr/sbin/pb-udhcpc "\$@"
EOF
    chmod 755 initramfs/usr/share/udhcpc/default.script
    cat << EOF > initramfs/etc/nsswitch.conf
passwd:                files
group:                files
shadow:                files
hosts:                files
networks:        files
protocols:        files
services:        files
ethers:                files
rpc:                files
netgroup:        files
EOF
    cat << EOF > initramfs/etc/group
root:x:0:
daemon:x:1:
tty:x:5:
disk:x:6:
lp:x:7:
kmem:x:15:
dialout:x:20:
cdrom:x:24:
tape:x:26:
audio:x:29:
video:x:44:
input:x:122:
EOF
    cat << EOF > initramfs/init
#!/bin/sh

/bin/busybox --install -s

CURRENT_TIMESTAMP=\$(date '+%s')
if [ \$CURRENT_TIMESTAMP -lt \$(date '+%s') ]; then
        date -s "@\$(date '+%s')"
fi

mount -t proc proc /proc
mount -t sysfs sysfs /sys
mount -t devtmpfs none /dev
 
echo 0 > /proc/sys/kernel/printk
clear
 
systemd-udevd &
udevadm hwdb --update
udevadm trigger

pb-discover &
petitboot-nc
 
if [ -e /etc/pb-lockdown ] ; then
        echo "Failed to launch petitboot, rebooting!"
        echo 1 > /proc/sys/kernel/sysrq
        echo b > /proc/sysrq-trigger
else
        echo "Failed to launch petitboot, dropping to a shell"
        exec sh
fi
EOF
    chmod +x initramfs/init
   
fi

C=$(find initramfs/usr/sbin/ -type f | grep -c petitboot || true)
if [ "$C" -lt 1 ] ; then
    (
        cd petitboot
        make DESTDIR="$(realpath ../../initramfs/)" install
    )
    cp initramfs/usr/local/sbin/* initramfs/usr/sbin/
    strip initramfs/{sbin/*,usr/sbin/*,lib/aarch64-linux-gnu/*,usr/lib/aarch64-linux-gnu/*,usr/lib/udev/*_id}
fi

if [ ! -f initramfs.igz ] ; then
    (
        cd initramfs
        find . | cpio -H newc -o | lzma > ../initramfs.igz
    )
    mkimage -A arm64 -O linux -T ramdisk -C lzma -a 0 -e 0 -n uInitrd.igz -d initramfs.igz uInitrd.igz
fi

echo "Everything it OK."

Wow!!! Cool!!! :o
I will try it in a couple of hours.

Hi elatllat,
Your script is amazing! It works well. :)
I just modified very small parts to fix some errors related to path.
Code: Select all
--- n1_uinitrd_install_elatllat.sh   2018-11-07 14:54:16.771378761 +0900
+++ build_uinitrd.sh   2018-11-07 14:55:10.000000000 +0900
@@ -4,7 +4,7 @@
 
 # prep
 C=$(id | grep -c "(root)" || true)
-if [ "$C" -gt 0 ] ; then
+if [ "$C" != 1 ] ; then
     echo "please re-run as root" >&2
     exit 1
 fi
@@ -71,12 +71,12 @@
 
 if [ ! -d petitboot ] ; then
     git clone --depth 1 -b petitboot-1.6.x https://github.com/open-power/petitboot.git
-    {
+    (
         cd petitboot
         ./bootstrap
         ./configure --with-twin-x11=no --with-twin-fbdev=no --with-signed-boot=no --disable-nls
         make -j "$(nproc)"
-    }
+    )
 fi
 
 if [ ! -d busybox ] ; then
@@ -84,8 +84,8 @@
     (
         cd busybox
         make defconfig
+        LDFLAGS=--static make -j "$(nproc)"
     )
-    LDFLAGS=--static make -j "$(nproc)"
 fi
 
 if [ ! -d initramfs ] ; then
@@ -101,6 +101,7 @@
 usr/sbin,\
 usr/lib/aarch64-linux-gnu,\
 usr/lib/udev/rules.d,\
+usr/local/sbin,\
 usr/share/udhcpc,\
 var/log/petitboot,run,\
 run/udev,\
@@ -153,7 +154,7 @@
     cp -Rp kexec-tools/build/sbin/kexec initramfs/sbin/
     cp -Rp systemd/{rules/*,build/rules/*} initramfs/usr/lib/udev/rules.d/
     rm -f initramfs/usr/lib/udev/rules.d/*-drivers.rules
-    cp -Rp busybox/busybox/examples/udhcp/simple.script initramfs/usr/share/udhcpc/simple.script
+    cp -Rp busybox/examples/udhcp/simple.script initramfs/usr/share/udhcpc/simple.script
     chmod 755 initramfs/usr/share/udhcpc/simple.script
     sed -i '/should be called from udhcpc/d' initramfs/usr/share/udhcpc/simple.script
     cat << EOF > initramfs/usr/share/udhcpc/default.script
@@ -230,10 +231,10 @@
 if [ "$C" -lt 1 ] ; then
     (
         cd petitboot
-        make DESTDIR="$(realpath ../../initramfs/)" install
+        make DESTDIR="$(realpath ../initramfs/)" install
     )
+    strip initramfs/{sbin/*,lib/aarch64-linux-gnu/*,usr/lib/aarch64-linux-gnu/*,usr/lib/udev/*_id}
     cp initramfs/usr/local/sbin/* initramfs/usr/sbin/
-    strip initramfs/{sbin/*,usr/sbin/*,lib/aarch64-linux-gnu/*,usr/lib/aarch64-linux-gnu/*,usr/lib/udev/*_id}
 fi
 
 if [ ! -f initramfs.igz ] ; then

Code: Select all
#!/bin/bash

set -e

# prep
C=$(id | grep -c "(root)" || true)
if [ "$C" != 1 ] ; then
    echo "please re-run as root" >&2
    exit 1
fi
C=$(apt-get --just-print upgrade | grep -cP "^Inst " || true)
if [ "$C" -gt 0 ] ; then
    apt-get update -y
    apt-get upgrade -y
    apt-get dist-upgrade -y
    echo "Please re-run after reboot."
    echo "Reboot now? [y|n]"
    read -r YN
    if [ "$YN" == "y" ] ; then
        reboot
    else
        exit 1
    fi
fi
apt-get install -y \
    git autoconf automake autopoint libtool pkg-config \
    libudev-dev libdevmapper-dev flex bison gettext \
    intltool libgcrypt20-dev \
    gperf libcap-dev libblkid-dev libmount-dev \
    xsltproc docbook-xsl docbook-xml python-lxml \
    libncurses5-dev libncursesw5-dev \
    libdw-dev libgpgme-dev
cd /home/odroid
mkdir -p ramdisk_petitboot
cd ramdisk_petitboot

if [ ! -d systemd ] ; then
    git clone --depth 1 git://anongit.freedesktop.org/systemd/systemd
    (
    cd systemd
        ./autogen.sh
        mkdir build
        (
            cd build
            ../configure --prefix=/usr --enable-blkid --disable-seccomp --disable-libcurl --disable-pam --disable-kmod
            make -j "$(nproc)"
        )
    )
fi

if [ ! -d kexec-tools ] ; then
    git clone --depth 1 git://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git
    (
        cd kexec-tools
        ./bootstrap
        ./configure --prefix=/usr
        make -j "$(nproc)"
    )
fi

if [ ! -d libtwin ] ; then
     git clone --depth 1 git://git.kernel.org/pub/scm/linux/kernel/git/geoff/libtwin.git
     (
         cd libtwin
         ./autogen.sh
         make
         make install
     )
fi


if [ ! -d petitboot ] ; then
    git clone --depth 1 -b petitboot-1.6.x https://github.com/open-power/petitboot.git
    (
        cd petitboot
        ./bootstrap
        ./configure --with-twin-x11=no --with-twin-fbdev=no --with-signed-boot=no --disable-nls
        make -j "$(nproc)"
    )
fi

if [ ! -d busybox ] ; then
    git clone  --depth 1 git://git.busybox.net/busybox
    (
        cd busybox
        make defconfig
        LDFLAGS=--static make -j "$(nproc)"
    )
fi

if [ ! -d initramfs ] ; then
    mkdir -p initramfs/{\
bin,\
sbin,\
etc,\
lib/aarch64-linux-gnu,\
proc,\
sys,\
newroot,\
usr/bin,\
usr/sbin,\
usr/lib/aarch64-linux-gnu,\
usr/lib/udev/rules.d,\
usr/local/sbin,\
usr/share/udhcpc,\
var/log/petitboot,run,\
run/udev,\
tmp}
    touch initramfs/etc/mdev.conf
    cp -Rp /lib/terminfo initramfs/lib/
    cp -Rp busybox/busybox initramfs/bin/
    ln -s busybox initramfs/bin/sh
    cp -L /lib/aarch64-linux-gnu/{\
libc.so.*,\
libm.so.*,\
libdl.so.*,\
librt.so.*,\
libacl.so.*,\
libcap.so.*,\
libattr.so.*,\
libpthread.so.*,\
libncurses.so.*,\
libncursesw.so.*,\
libtinfo.so.*,\
libpcre.so.*,\
libresolv.so.*,\
libselinux.so.*,\
libreadline.so.*,\
libgcc_s.so.*,\
libblkid.so.*,\
libkmod.so.*,\
libuuid.so.*,\
libusb-1.0.so.*,\
libdevmapper.so.*,\
libz.so.*,\
liblzma.so.*,\
libbz2.so.*,\
libgpg-error.so.*,\
libnss_files.so.*} initramfs/lib/aarch64-linux-gnu/
    cp -L /lib/ld-linux-aarch64.so.* initramfs/lib/
    cp -L /usr/lib/aarch64-linux-gnu/{\
libform.so.*,\
libformw.so.*,\
libmenu.so.*,\
libmenuw.so.*,\
libelf.so.*,\
libdw.so.*,\
libgpgme.so.*,\
libassuan.so.*} initramfs/usr/lib/aarch64-linux-gnu/
    cp -Rp /usr/bin/gpg initramfs/usr/bin/
    cp systemd/build/.libs/libudev.so.* initramfs/lib/aarch64-linux-gnu/
    cp -Rp systemd/build/{systemd-udevd,udevadm} initramfs/sbin/
    cp -Rp systemd/build/*_id initramfs/usr/lib/udev/
    cp -Rp kexec-tools/build/sbin/kexec initramfs/sbin/
    cp -Rp systemd/{rules/*,build/rules/*} initramfs/usr/lib/udev/rules.d/
    rm -f initramfs/usr/lib/udev/rules.d/*-drivers.rules
    cp -Rp busybox/examples/udhcp/simple.script initramfs/usr/share/udhcpc/simple.script
    chmod 755 initramfs/usr/share/udhcpc/simple.script
    sed -i '/should be called from udhcpc/d' initramfs/usr/share/udhcpc/simple.script
    cat << EOF > initramfs/usr/share/udhcpc/default.script
#!/bin/sh

/usr/share/udhcpc/simple.script "\$@"
/usr/sbin/pb-udhcpc "\$@"
EOF
    chmod 755 initramfs/usr/share/udhcpc/default.script
    cat << EOF > initramfs/etc/nsswitch.conf
passwd:                files
group:                files
shadow:                files
hosts:                files
networks:        files
protocols:        files
services:        files
ethers:                files
rpc:                files
netgroup:        files
EOF
    cat << EOF > initramfs/etc/group
root:x:0:
daemon:x:1:
tty:x:5:
disk:x:6:
lp:x:7:
kmem:x:15:
dialout:x:20:
cdrom:x:24:
tape:x:26:
audio:x:29:
video:x:44:
input:x:122:
EOF
    cat << EOF > initramfs/init
#!/bin/sh

/bin/busybox --install -s

CURRENT_TIMESTAMP=\$(date '+%s')
if [ \$CURRENT_TIMESTAMP -lt \$(date '+%s') ]; then
        date -s "@\$(date '+%s')"
fi

mount -t proc proc /proc
mount -t sysfs sysfs /sys
mount -t devtmpfs none /dev
 
echo 0 > /proc/sys/kernel/printk
clear
 
systemd-udevd &
udevadm hwdb --update
udevadm trigger

pb-discover &
petitboot-nc
 
if [ -e /etc/pb-lockdown ] ; then
        echo "Failed to launch petitboot, rebooting!"
        echo 1 > /proc/sys/kernel/sysrq
        echo b > /proc/sysrq-trigger
else
        echo "Failed to launch petitboot, dropping to a shell"
        exec sh
fi
EOF
    chmod +x initramfs/init
   
fi

C=$(find initramfs/usr/sbin/ -type f | grep -c petitboot || true)
if [ "$C" -lt 1 ] ; then
    (
        cd petitboot
        make DESTDIR="$(realpath ../initramfs/)" install
    )
    strip initramfs/{sbin/*,lib/aarch64-linux-gnu/*,usr/lib/aarch64-linux-gnu/*,usr/lib/udev/*_id}
    cp initramfs/usr/local/sbin/* initramfs/usr/sbin/
fi

if [ ! -f initramfs.igz ] ; then
    (
        cd initramfs
        find . | cpio -H newc -o | lzma > ../initramfs.igz
    )
    mkimage -A arm64 -O linux -T ramdisk -C lzma -a 0 -e 0 -n uInitrd.igz -d initramfs.igz uInitrd.igz
fi

echo "Everything it OK."

And I will add descriptions about the script in the installation guide.

Thank you again!
Last edited by joy on Wed Nov 07, 2018 3:39 pm, edited 1 time in total.
joy
 
Posts: 571
Joined: Fri Oct 02, 2015 1:44 pm
languages_spoken: english
ODROIDs: ODROID-C1+, XU4, X

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby mad_ady » Wed Nov 07, 2018 3:13 pm

The script should live on github, not on the forum, for easier maintenance/deployment
User avatar
mad_ady
 
Posts: 4711
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby joy » Wed Nov 07, 2018 3:35 pm

mad_ady wrote:The script should live on github, not on the forum, for easier maintenance/deployment

@mad_ady,
Thank you for the opinion.
You're right.

@elatllat,
Do you have a github to maintain your script?
Which one is better to maintain it on your github or on Hardkernel github?
joy
 
Posts: 571
Joined: Fri Oct 02, 2015 1:44 pm
languages_spoken: english
ODROIDs: ODROID-C1+, XU4, X

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby phaseshifter » Wed Nov 07, 2018 6:59 pm

Hmm ..ok i have been out for a while and the thread has progressed so much ..if i have time tonight i will flash a fresh image..i am using an emmc..
i dont bother with sd-cards..if i can avoid them..
A Big thank you to all who have helped and to @joy for working so much on the updates that were required..
i can only use the test image from H-K..as it stands ..
my skills in this type of work are limited but i still give it all that i can..
i will report errors as they occur as i go through the build process..

prolly do it tonite
Build It And They Will Come...Be Bold And Mighty Forces Will Come To Your Aid..!!!
phaseshifter
 
Posts: 2970
Joined: Fri May 08, 2015 9:12 am
languages_spoken: english
ODROIDs: N-1..c1+ ..c-2..xu3 lite,xu4...u-3..
u-2...other odroid acc`s as well

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby phaseshifter » Wed Nov 07, 2018 8:14 pm

ok i used the auto scrypt by @ellatte`s install
question`s
1: what step do i do next...... i will try however
2: does all this have to be dumped on a hdd

sorry for my xexperiance
Build It And They Will Come...Be Bold And Mighty Forces Will Come To Your Aid..!!!
phaseshifter
 
Posts: 2970
Joined: Fri May 08, 2015 9:12 am
languages_spoken: english
ODROIDs: N-1..c1+ ..c-2..xu3 lite,xu4...u-3..
u-2...other odroid acc`s as well

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby phaseshifter » Wed Nov 07, 2018 8:37 pm

ok i used the auto install scrypt seened easier 4 me.it threw somwe warning`s and i think some errors i will post them...
so i am not shure what to do next.....

this was at the end of the installl

Image Name: uInitrd.igz
Created: Wed Nov 7 11:28:16 2018
Image Type: AArch64 Linux RAMDisk Image (lzma compressed)
Data Size: 3541284 Bytes = 3458.29 kB = 3.38 MB
Load Address: 00000000
Entry Point: 00000000
Everything it OK.

these i think were error`s

Code: Select all
  CC       libtwin/twin_draw.lo
libtwin/twin_draw.c: In function ‘twin_pixmap_read_xform_16’:
libtwin/twin_draw.c:466:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  _get_pix_16(pts[0], pix, sx, sy);
  ^~~~~~~~~~~
libtwin/twin_draw.c:467:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  _get_pix_16(pts[1], pix, sx + TWIN_FIXED_ONE, sy);
  ^~~~~~~~~~~
libtwin/twin_draw.c:468:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  _get_pix_16(pts[2], pix, sx, sy + TWIN_FIXED_ONE);
  ^~~~~~~~~~~
libtwin/twin_draw.c:469:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  _get_pix_16(pts[3], pix, sx + TWIN_FIXED_ONE, sy + TWIN_FIXED_ONE);
  ^~~~~~~~~~~
libtwin/twin_draw.c: In function ‘twin_pixmap_read_xform_32’:
libtwin/twin_draw.c:497:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  _get_pix_32(pts[0], pix, sx, sy);
  ^~~~~~~~~~~
libtwin/twin_draw.c:498:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  _get_pix_32(pts[1], pix, sx + TWIN_FIXED_ONE, sy);
  ^~~~~~~~~~~
libtwin/twin_draw.c:499:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  _get_pix_32(pts[2], pix, sx, sy + TWIN_FIXED_ONE);
  ^~~~~~~~~~~
libtwin/twin_draw.c:500:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  _get_pix_32(pts[3], pix, sx + TWIN_FIXED_ONE, sy + TWIN_FIXED_ONE);
  ^~~~~~~~~~~
libtwin/twin_draw.c: In function ‘_twin_apply_alpha’:
libtwin/twin_draw.c:656:5: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
     if (__BYTE_ORDER == __BIG_ENDIAN)
     ^~
libtwin/twin_draw.c:662:2: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘if’
  return alpha << 24 |
  ^~~~~~
libtwin/twin_draw.c: In function ‘twin_pixmap_read_xform’:
libtwin/twin_draw.c:448:54: warning: ‘pts[4]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  *(dst++) = _pix_saucemix(pts[0], pts[1], pts[2], pts[4], wx, wy);
                                                      ^
libtwin/twin_draw.c:432:15: note: ‘pts[4]’ was declared here
     twin_a8_t pts[4];
               ^~~
  CC       libtwin/twin_feature.lo
  CC       libtwin/twin_hull.lo
  CC       libtwin/twin_icon.lo
  CC       libtwin/twin_file.lo
  CC       libtwin/twin_fixed.lo
  CC       libtwin/twin_font.lo
  CC       libtwin/twin_font_default.lo
  CC       libtwin/twin_geom.lo
  CC       libtwin/twin_label.lo
libtwin/twin_label.c: In function ‘_twin_label_dispatch’:
libtwin/twin_label.c:71:4: warning: ‘x’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  x += label->offset.x;
  ~~^~~~~~~~~~~~~~~~~~
libtwin/twin_label.c:54:15: note: ‘x’ was declared here
  twin_fixed_t x, y;
               ^
  CC       libtwin/twin_matrix.lo
  CC       libtwin/twin_path.lo
  CC       libtwin/twin_pattern.lo
  CC       libtwin/twin_pixmap.lo
  CC       libtwin/twin_poly.lo
  CC       libtwin/twin_primitive.lo
  CC       libtwin/twin_queue.lo
  CC       libtwin/twin_screen.lo
  CC       libtwin/twin_spline.lo
  CC       libtwin/twin_timeout.lo
  CC       libtwin/twin_toplevel.lo
libtwin/twin_toplevel.c: In function ‘_twin_toplevel_init’:
libtwin/twin_toplevel.c:82:17: warning: variable ‘extents’ set but not used [-Wunused-but-set-variable]
     twin_rect_t extents;
                 ^~~~~~~
  CC       libtwin/twin_trig.lo
  CC       libtwin/twin_widget.lo
  CC       libtwin/twin_window.lo
  CC       libtwin/twin_work.lo
  CC       libtwin/twin_x11.lo
libtwin/twin_x11.c: In function ‘twin_x11_create_ext’:
libtwin/twin_x11.c:152:21: warning: variable ‘classHints’ set but not used [-Wunused-but-set-variable]
     XClassHint      classHints;
                     ^~~~~~~~~~
Build It And They Will Come...Be Bold And Mighty Forces Will Come To Your Aid..!!!
phaseshifter
 
Posts: 2970
Joined: Fri May 08, 2015 9:12 am
languages_spoken: english
ODROIDs: N-1..c1+ ..c-2..xu3 lite,xu4...u-3..
u-2...other odroid acc`s as well

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby phaseshifter » Wed Nov 07, 2018 8:43 pm

now this appeared on my terminal not shure how it occured...

Code: Select all
root@odroid:/# Image Name:   uInitrd.igz
Could not find the database of available applications, run update-command-not-found as root to fix this
Image: command not found
root@odroid:/# Created:      Wed Nov  7 11:28:16 2018
Could not find the database of available applications, run update-command-not-found as root to fix this
Created:: command not found
root@odroid:/# Image Type:   AArch64 Linux RAMDisk Image (lzma compressed)
bash: syntax error near unexpected token `('
root@odroid:/# Data Size:    3541284 Bytes = 3458.29 kB = 3.38 MB
Could not find the database of available applications, run update-command-not-found as root to fix this
Data: command not found
root@odroid:/# Load Address: 00000000
Could not find the database of available applications, run update-command-not-found as root to fix this
Load: command not found
root@odroid:/# Entry Point:  00000000
Could not find the database of available applications, run update-command-not-found as root to fix this
Entry: command not found
root@odroid:/# Everything it OK.
Could not find the database of available applications, run update-command-not-found as root to fix this
Everything: command not found
root@odroid:/# update-command-not-found
I: Writing data for http.debian.net_debian_dists_stretch_main_Contents-arm64.lz4 ... . done
I: Writing data for http.debian.net_debian_dists_stretch_contrib_Contents-arm64.lz4 ... . done
I: Writing data for http.debian.net_debian_dists_stretch-updates_main_Contents-arm64.lz4 ... . done
I: Writing data for http.debian.net_debian_dists_stretch_non-free_Contents-arm64.lz4 ... . done
root@odroid:/#
Build It And They Will Come...Be Bold And Mighty Forces Will Come To Your Aid..!!!
phaseshifter
 
Posts: 2970
Joined: Fri May 08, 2015 9:12 am
languages_spoken: english
ODROIDs: N-1..c1+ ..c-2..xu3 lite,xu4...u-3..
u-2...other odroid acc`s as well

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby phaseshifter » Wed Nov 07, 2018 8:45 pm

so i`ll leave it as is and power down the N-1 till i get further input as what to do next...

pss do i need to dump this code..etc.etc to a blank sd card or ..????
Build It And They Will Come...Be Bold And Mighty Forces Will Come To Your Aid..!!!
phaseshifter
 
Posts: 2970
Joined: Fri May 08, 2015 9:12 am
languages_spoken: english
ODROIDs: N-1..c1+ ..c-2..xu3 lite,xu4...u-3..
u-2...other odroid acc`s as well

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby mad_ady » Wed Nov 07, 2018 8:54 pm

You were getting warnings - they're ok, we only care about errors.
The other post is when you accidentally pasted what you copied on the shell and it tried to execute the text. :)
User avatar
mad_ady
 
Posts: 4711
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby phaseshifter » Wed Nov 07, 2018 9:45 pm

ok thanks @mad_ady..

can you or anybody tell me where to start next then ..
i`m lost as where to start on @joy`s page...
Build It And They Will Come...Be Bold And Mighty Forces Will Come To Your Aid..!!!
phaseshifter
 
Posts: 2970
Joined: Fri May 08, 2015 9:12 am
languages_spoken: english
ODROIDs: N-1..c1+ ..c-2..xu3 lite,xu4...u-3..
u-2...other odroid acc`s as well

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby elatllat » Wed Nov 07, 2018 11:47 pm

phaseshifter wrote:ok thanks @mad_ady..

can you or anybody tell me where to start next then ..
i`m lost as where to start on @joy`s page...

after the script continue with "[ Kernel Configuration ]"
elatllat
 
Posts: 1066
Joined: Tue Sep 01, 2015 8:54 am
languages_spoken: english
ODROIDs: XU4, N1

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby elatllat » Wed Nov 07, 2018 11:52 pm

joy wrote:...
@elatllat,
Do you have a github to maintain your script?
Which one is better to maintain it on your github or on Hardkernel github?


Please use (or fork from) the version on github.... should probably edit old versions out of this thread history.
I attributed Joy for most of the work in the log.
Last edited by elatllat on Thu Nov 08, 2018 8:49 am, edited 1 time in total.
elatllat
 
Posts: 1066
Joined: Tue Sep 01, 2015 8:54 am
languages_spoken: english
ODROIDs: XU4, N1

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby phaseshifter » Wed Nov 07, 2018 11:57 pm

thank`s @elatllat...i thought that was it but i did see references to the kerne;l whilst i was running the auto install of your`s

sorry for being the noob at this guy`s...
Build It And They Will Come...Be Bold And Mighty Forces Will Come To Your Aid..!!!
phaseshifter
 
Posts: 2970
Joined: Fri May 08, 2015 9:12 am
languages_spoken: english
ODROIDs: N-1..c1+ ..c-2..xu3 lite,xu4...u-3..
u-2...other odroid acc`s as well

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby phaseshifter » Thu Nov 08, 2018 12:22 am

ok what am i doing wrong here pls...


Code: Select all
root@odroid:/# patch -p1 < ../0001_n1_add_kexec.diff
can't find file to patch at input line 13
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|From 705d73ddaf70ea7ece5584d0514067f8fd8bf8be Mon Sep 17 00:00:00 2001
|From: joy <joy.cho@hardkernel.com>
|Date: Thu, 29 Mar 2018 16:15:15 +0900
|Subject: [PATCH] defconfig: odroidn1: activate kexec configuration
|
|Change-Id: I5c31c90630e80a85e02b45613b41ae1164ab57a3
|---
|
|diff --git a/arch/arm64/configs/odroidn1_defconfig b/arch/arm64/configs/odroidn1_defconfig
|index 89867cf..50a2f06 100644
|--- a/arch/arm64/configs/odroidn1_defconfig
|+++ b/arch/arm64/configs/odroidn1_defconfig
--------------------------
File to patch: 0001_n1_add_kexec.diff
patching file 0001_n1_add_kexec.diff
Hunk #1 FAILED at 200.
Hunk #2 FAILED at 448.
2 out of 2 hunks FAILED -- saving rejects to file 0001_n1_add_kexec.diff.rej
root@odroid:/#
Build It And They Will Come...Be Bold And Mighty Forces Will Come To Your Aid..!!!
phaseshifter
 
Posts: 2970
Joined: Fri May 08, 2015 9:12 am
languages_spoken: english
ODROIDs: N-1..c1+ ..c-2..xu3 lite,xu4...u-3..
u-2...other odroid acc`s as well

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby mad_ady » Thu Nov 08, 2018 12:31 am

You need to copy the patch inside the kernel source dir and cd into the kernel source dir before running the patch command.
User avatar
mad_ady
 
Posts: 4711
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby phaseshifter » Thu Nov 08, 2018 1:04 am

would this dir be the one to copy the files into..

Code: Select all
/usr/src
Build It And They Will Come...Be Bold And Mighty Forces Will Come To Your Aid..!!!
phaseshifter
 
Posts: 2970
Joined: Fri May 08, 2015 9:12 am
languages_spoken: english
ODROIDs: N-1..c1+ ..c-2..xu3 lite,xu4...u-3..
u-2...other odroid acc`s as well

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby elatllat » Thu Nov 08, 2018 1:07 am

phaseshifter wrote:...patch...

in the midst of https://wiki.odroid.com/odroid-n1/softw ... ing_kernel
That's why I said I only started the script (a lot can still be added to the end)
elatllat
 
Posts: 1066
Joined: Tue Sep 01, 2015 8:54 am
languages_spoken: english
ODROIDs: XU4, N1

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby mad_ady » Thu Nov 08, 2018 1:32 am

@phaseshifter - the kernel source dir is where git clone put it. Probably linux* or kernel* in your home directory.
User avatar
mad_ady
 
Posts: 4711
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby phaseshifter » Thu Nov 08, 2018 5:04 am

ok i built it manually..

step 10

errors..that is about all up to kernel building..

root@odroid:/home/odroid/ramdisk_petitboot# strip initramfs/usr/sbin/*
strip:initramfs/usr/sbin/pb-exec: File format not recognized
strip:initramfs/usr/sbin/pb-plugin: File format not recognized
strip:initramfs/usr/sbin/pb-sos: File format not recognized
strip:initramfs/usr/sbin/pb-udhcpc: File format not recognized
Build It And They Will Come...Be Bold And Mighty Forces Will Come To Your Aid..!!!
phaseshifter
 
Posts: 2970
Joined: Fri May 08, 2015 9:12 am
languages_spoken: english
ODROIDs: N-1..c1+ ..c-2..xu3 lite,xu4...u-3..
u-2...other odroid acc`s as well

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby joy » Thu Nov 08, 2018 7:57 am

phaseshifter wrote:ok i built it manually..

step 10

errors..that is about all up to kernel building..

root@odroid:/home/odroid/ramdisk_petitboot# strip initramfs/usr/sbin/*
strip:initramfs/usr/sbin/pb-exec: File format not recognized
strip:initramfs/usr/sbin/pb-plugin: File format not recognized
strip:initramfs/usr/sbin/pb-sos: File format not recognized
strip:initramfs/usr/sbin/pb-udhcpc: File format not recognized

Thank you, phaseshifter!
I updated the manual guide now and it has been applied to auto script already.
joy
 
Posts: 571
Joined: Fri Oct 02, 2015 1:44 pm
languages_spoken: english
ODROIDs: ODROID-C1+, XU4, X

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby phaseshifter » Thu Nov 08, 2018 10:42 am

ok i downloaded the kernel from the "kernel build N-1" wiki page but still having trouble with applying the patches...

the wiki is not that imfomative about adding patches ..

i went through my "phase spi progress" thread and found the way to do it so it would seem but still it`s not working 4 me...

so i`m stuck at building the kernel..i think once i get past this the rest i should be able to do....
Build It And They Will Come...Be Bold And Mighty Forces Will Come To Your Aid..!!!
phaseshifter
 
Posts: 2970
Joined: Fri May 08, 2015 9:12 am
languages_spoken: english
ODROIDs: N-1..c1+ ..c-2..xu3 lite,xu4...u-3..
u-2...other odroid acc`s as well

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby joy » Thu Nov 08, 2018 10:58 am

phaseshifter wrote:ok i downloaded the kernel from the "kernel build N-1" wiki page but still having trouble with applying the patches...

the wiki is not that imfomative about adding patches ..

i went through my "phase spi progress" thread and found the way to do it so it would seem but still it`s not working 4 me...

so i`m stuck at building the kernel..i think once i get past this the rest i should be able to do....

I see.
As you said, further explanation is needed.
I will update the part to apply patches and build kernel soon.
joy
 
Posts: 571
Joined: Fri Oct 02, 2015 1:44 pm
languages_spoken: english
ODROIDs: ODROID-C1+, XU4, X

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby joy » Thu Nov 08, 2018 11:03 am

phaseshifter wrote:ok thanks @mad_ady..

can you or anybody tell me where to start next then ..
i`m lost as where to start on @joy`s page...


As you're doing now, please check [Kernel Configuration] to build a new kernel for petitboot running
then follow these in sequential order please.
2. [ Kernel Configuration ]
3. [ Booting from 1st strorage (your eMMC) and Load petitboot application ]
4. [ Add a boot option ] and Jump to 2nd kernel from 2nd storage (like USB, SD or SATA disk)
joy
 
Posts: 571
Joined: Fri Oct 02, 2015 1:44 pm
languages_spoken: english
ODROIDs: ODROID-C1+, XU4, X

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby joy » Thu Nov 08, 2018 2:54 pm

elatllat wrote:Please use (or fork from) the version on github.... should probably edit old versions out of this thread history.
I attributed Joy for most of the work in the log.

Thank you, elatllat.
Once the whole process with petitboot works perfectly, current issues are fixed so ready to release, let's discuss if we maintain it on Hardkernel Github.
First, I did fork it into my personal Github from your Github.
joy
 
Posts: 571
Joined: Fri Oct 02, 2015 1:44 pm
languages_spoken: english
ODROIDs: ODROID-C1+, XU4, X

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby phaseshifter » Fri Nov 09, 2018 12:41 am

I`ve left it at the kerenel build stage soz about that
i will do more tomorrow but i`m exhausted atm need some ZZZ,zzz
Build It And They Will Come...Be Bold And Mighty Forces Will Come To Your Aid..!!!
phaseshifter
 
Posts: 2970
Joined: Fri May 08, 2015 9:12 am
languages_spoken: english
ODROIDs: N-1..c1+ ..c-2..xu3 lite,xu4...u-3..
u-2...other odroid acc`s as well

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby phaseshifter » Fri Nov 09, 2018 3:03 am

@joy pls...and thaks to @mad_ady as well...but i thought my question was simple and straight forward..no diss to any op`s...

well steps i have taken to download and build the kernel thus far...
Code: Select all
mkdir linux

Code: Select all
cd linux

downloaded the linux files to the linux dir..

now i`m stuck as to which directory i should be in to download and unzip the patch files into ...
and proceed further with the make process..
if you could assist me with this then i should be able to proceed further..
thank`s ..phase..

as i am shure i mentioned earlier the guide that i am following is this which is most prolly more code here than is necessary
and solely not correct for the application at hand.

Code: Select all
make distclean
patch -p1 < ../0003_n1_spi_mtd_config_dts.diff
make odroidn1_defconfig
make Image dtbs -j5
sudo cp arch/arm64/boot/Image /media/boot/Image
sudo cp arch/arm64/boot/dts/rockchip/rk3399-odroidn1-linux.dtb /media/boot/rk3399-odroidn1-linux.dtb
sudo make modules
sudo make modules_install
sudo cp .config /boot/config-`cat include/config/kernel.release`
sudo update-initramfs -c -k `cat include/config/kernel.release`
sudo mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 -n uInitrd -d /boot/initrd.img-`cat include/config/kernel.release` /boot/uInitrd-`cat include/config/kernel.release`
sudo cp /media/boot/uInitrd /boot/uInitrd-`uname -r`
Last edited by phaseshifter on Fri Nov 09, 2018 3:53 am, edited 2 times in total.
Build It And They Will Come...Be Bold And Mighty Forces Will Come To Your Aid..!!!
phaseshifter
 
Posts: 2970
Joined: Fri May 08, 2015 9:12 am
languages_spoken: english
ODROIDs: N-1..c1+ ..c-2..xu3 lite,xu4...u-3..
u-2...other odroid acc`s as well

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby mad_ady » Fri Nov 09, 2018 3:16 am

This guide explains quite well how you compile a kernel: https://github.com/umiddelb/armhf/wiki/ ... ARM-device
User avatar
mad_ady
 
Posts: 4711
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby joy » Fri Nov 09, 2018 7:59 am

phaseshifter wrote:@joy pls...and thaks to @mad_ady as well...but i thought my question was simple and straight forward..no diss to any op`s...

well steps i have taken to download and build the kernel thus far...
Code: Select all
mkdir linux

Code: Select all
cd linux

downloaded the linux files to the linux dir..

now i`m stuck as to which directory i should be in to download and unzip the patch files into ...
and proceed further with the make process..
if you could assist me with this then i should be able to proceed further..
thank`s ..phase..

as i am shure i mentioned earlier the guide that i am following is this which is most prolly more code here than is necessary
and solely not correct for the application at hand.

Code: Select all
make distclean
patch -p1 < ../0003_n1_spi_mtd_config_dts.diff
make odroidn1_defconfig
make Image dtbs -j5
sudo cp arch/arm64/boot/Image /media/boot/Image
sudo cp arch/arm64/boot/dts/rockchip/rk3399-odroidn1-linux.dtb /media/boot/rk3399-odroidn1-linux.dtb
sudo make modules
sudo make modules_install
sudo cp .config /boot/config-`cat include/config/kernel.release`
sudo update-initramfs -c -k `cat include/config/kernel.release`
sudo mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 -n uInitrd -d /boot/initrd.img-`cat include/config/kernel.release` /boot/uInitrd-`cat include/config/kernel.release`
sudo cp /media/boot/uInitrd /boot/uInitrd-`uname -r`

Hi phaseshifter,

So you mean you want the instructions described in this thread.
Yesterday I modified the above instruction.
I mentioned the following wiki page on the above guide after you said,
and the page specified the process.
Code: Select all
[ Step 2. Kernel Configuration ]

(1) Preparation and Download Kernel
You can refer to this wiki page.
https://wiki.odroid.com/odroid-n1/software/building_kernel
https://wiki.odroid.com/odroid-n1/software/building_kernel#download_and_build_2_-_linux
joy
 
Posts: 571
Joined: Fri Oct 02, 2015 1:44 pm
languages_spoken: english
ODROIDs: ODROID-C1+, XU4, X

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby rooted » Fri Nov 09, 2018 8:09 am

You want the patches just outside the kernel source directory.

You want to be inside the kernel source directory when you apply them.
User avatar
rooted
 
Posts: 5681
Joined: Fri Dec 19, 2014 9:12 am
Location: Gulf of Mexico, US
languages_spoken: english
ODROIDs: C1, C1+, C2
XU3 Lite, XU4
N1
VU7+
HiFi Shield 2
Smart Power (original)

Re: BIOS design using PETITBOOT to support SPI booting

Unread postby phaseshifter » Fri Nov 09, 2018 9:06 am

ok so the patches can be in the linux directory ..

but everybody keep`s telling me exactly what im hearing"the kernel source directory"

sorry but my device tree structure skills with linux are somewhat limited

so is it /src/arch64/.../...etc..etc i dunno exactly where the correct directory is exactly.or where i should be running the make file etc etc...

.sorry for my inexperience...

the wiki pages seem somewhat limited in my op..

well i am no master at kernel building...sozz but i`m quite tiresome i have put in sooo many hours on this project i anit a young buck any more...
Build It And They Will Come...Be Bold And Mighty Forces Will Come To Your Aid..!!!
phaseshifter
 
Posts: 2970
Joined: Fri May 08, 2015 9:12 am
languages_spoken: english
ODROIDs: N-1..c1+ ..c-2..xu3 lite,xu4...u-3..
u-2...other odroid acc`s as well

Next

Return to Projects

Who is online

Users browsing this forum: No registered users and 1 guest