Ubuntu desktop 2 logins needed

Will add this one to the repository until RADXA has it.

in idle mode with mate, CPU is quite cool, running with 408MHz:

408000
408000
408000
408000
408000
408000

I installed and created installation :slight_smile: from SD card to LVM, where FLASHDEFAULTLVM would do following:

  1. as boot device, eMMC is choosen
  2. eMMC’s free space is added to Volume Group
  3. Scan for all USB connected disks
  4. Add all connected USB disks to the LVM (creates first new GPT, then 1 part, then adds it to the LVM)
  5. Add all connected M2 disks (I just assume in future we will be able to have 2 or more of them)
  6. Create LVM and install ubuntu bionic miniamal

:slight_smile: all works fine until now… :), PARTUUID on LVM is that way also the same

Now I am unsure if that is good one for default, I kinda wouldnt like to make raid0 with fast m2 and much slower emmc, thats why I though, if somebody has m2 and 128gb emmc’s, then it only is complicated to use its free space if only boot is required, thats why I add it mmcblk devices after m2 devices,

this is example of LVM if ~128GB:

Disk /dev/mapper/rootfsVG-rootfsLV: 115.1 GiB, 123593555968 bytes, 241393664 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 992DF2C2-0170-4F66-9492-FBF320673EEF

Device                                       Start     End Sectors  Size Type
/dev/mapper/rootfsVG-rootfsLV-part1     64    8063    8000  3.9M Linux filesystem
/dev/mapper/rootfsVG-rootfsLV-part2  16384   24575    8192    4M Linux filesystem
/dev/mapper/rootfsVG-rootfsLV-part3  24576   32767    8192    4M Linux filesystem
/dev/mapper/rootfsVG-rootfsLV-part4  32768  262143  229376  112M EFI System
/dev/mapper/rootfsVG-rootfsLV-part5 262144 4458462 4196319    2G Linux filesystem

Which USB disks to take is configured with USBDISKSFORLVM="a-z"
Volume group name is set by: ROOTVLNAME="rootfs" # Volume group name

and that would be it on required settings.

If somebody has some wishes regarding this, then write it now :slight_smile:

for FLASHDEFAULTRAID0, I actually create only raid for USB disks, however, raid0 is not finished, have to test it and write a part where I will create only raid0 with available pair, then add it to LVM, as if at the end 1 disk is left (lets say you use 5 USB disks) then it is quite usefull to add it to the :slight_smile: LVM after raid0, as well as I add then emmc’s free part, resulting in a LVM which consists of mixed RAID0 on USB’s, M2 and emmc, all as one disk on which :slight_smile: ubuntu-bionic is installed, have to get me today 2 of same m2.ssd’s so that I can test raid0 properly, will report in the evening…

Just to show (its dirty, some things could be better optimized etc…, but it works):

#!/bin/sh

BOOTDEVICE="mmcblk1" # eMMC per default, if it does not exist, SD card will be used instead automaticaly
ROOTVLNAME="rootfs" # Volume group name
ROOTDEVICE="${ROOTVLNAME}VG-${ROOTVLNAME}LV"
LVMDEVICEGROUP=""
USBDISKSFORLVM="a-z"
echo "FLASHDEFAULTM2 LOG START" > /tmp/$FLASHIMGXZ.log
echo "Zero format of eMMC's internal card" >> /tmp/$FLASHIMGXZ.log
/usr/bin/FLASHeMMC1.sh

# fix GPT partition
(
echo x
echo e
echo Y
echo w
echo Y
) | gdisk /dev/mmcblk1
# Delete rootfs partition on eMMC card and create empty ext4
(
echo d # delete partition
echo 5 # partition number
echo n # Add a new partition
echo 5 # partition number
echo   # Accept default (First sector (34-4458462, default = 262144) or {+-}size{KMGTP})
echo   # Accept default (Last sector (262144-4458462, default = 4458462) or {+-}size{KMGTP})
echo   # Accept default (Hex code or GUID (L to show codes, Enter = 8300)
echo w # Write changes
echo Y # confirm
echo Y # confirm
) | gdisk /dev/mmcblk1


# Format all currently connected USB disks
## fix GPT partition
(
echo x
echo e
echo Y
echo w
echo Y
) | gdisk /dev/mmcblk1

# On rockpit 4 only 2 boot devices are support: mmcblk0 and mmcblk1
if [ "$BOOTDEVICE"=="mmcblk0" ];then 
    # using SD card as boot device:     for FOUNDPART in $(fdisk -l | grep -Eo 'mmcblk[0-9]p[0-9]+')
    #for FOUNDPART in $(fdisk -l | grep -Eo 'mmcblk[1-9]p[0-1]+')
    # WARNING - IF YOU USE SD CARD AS BOOT, YOU NEED TO BOOT AND RUN THIS SCRIPT FROM ANOTHER DEVICE
    for FOUNDPART in $(fdisk -l | grep -Eo 'mmcblk[0-9]p1+')
    do
        (
        echo o # delete partition
        echo Y # partition number
        echo n # Add a new partition
        echo 1 # partition number
        echo   # Accept default (First sector (34-4458462, default = 262144) or {+-}size{KMGTP})
        echo   # Accept default (Last sector (262144-4458462, default = 4458462) or {+-}size{KMGTP})
        echo   # Accept default (Hex code or GUID (L to show codes, Enter = 8300)
        echo w # Write changes
        echo Y # confirm
        echo Y # confirm
        ) | gdisk /dev/${FOUNDPART}
        # create LVM
        (
        echo y
        ) | pvcreate /dev/${FOUNDPART}

        # Add to lvm device group
        LVMDEVICEGROUP="$LVMDEVICEGROUP /dev/${FOUNDPART}"
    done
else
    # using eMMC card as boot device and so we will format only mmcblk1
    for FOUNDPART in $(fdisk -l | grep -Eo 'mmcblk[1-9]p1+')
    do
        (
        echo o # delete partition
        echo Y # partition number
        echo n # Add a new partition
        echo 1 # partition number
        echo   # Accept default (First sector (34-4458462, default = 262144) or {+-}size{KMGTP})
        echo   # Accept default (Last sector (262144-4458462, default = 4458462) or {+-}size{KMGTP})
        echo   # Accept default (Hex code or GUID (L to show codes, Enter = 8300)
        echo w # Write changes
        echo Y # confirm
        echo Y # confirm
        ) | gdisk /dev/${FOUNDPART}

        # create LVM
        (
        echo y
        ) | pvcreate /dev/${FOUNDPART}

        LVMDEVICEGROUP="$LVMDEVICEGROUP /dev/${FOUNDPART}"
    done
fi

# Remove first occurency of space in front of the string
LVMDEVICEGROUP=$(echo $LVMDEVICEGROUP | sed -i 's/  //')

# using SD card as boot device:     for FOUNDPART in $(fdisk -l | grep -Eo 'mmcblk[0-9]p[0-9]+')
#for FOUNDPART in $(fdisk -l | grep -Eo 'mmcblk[1-9]p[0-1]+')
# WARNING - IF YOU USE SD CARD AS BOOT, YOU NEED TO BOOT AND RUN THIS SCRIPT FROM ANOTHER DEVICE
for FOUNDPART in $(fdisk -l | grep -Eo "sd[${USBDISKSFORLVM}]+")
do
    (
    echo o # delete partition
    echo Y # partition number
    echo n # Add a new partition
    echo 1 # partition number
    echo   # Accept default (First sector (34-4458462, default = 262144) or {+-}size{KMGTP})
    echo   # Accept default (Last sector (262144-4458462, default = 4458462) or {+-}size{KMGTP})
    echo   # Accept default (Hex code or GUID (L to show codes, Enter = 8300)
    echo w # Write changes
    echo Y # confirm
    echo Y # confirm
    ) | gdisk /dev/${FOUNDPART}

    # create LVM
    (
    echo y
    ) | pvcreate /dev/${FOUNDPART}1

    LVMDEVICEGROUP="$LVMDEVICEGROUP /dev/${FOUNDPART}1"
done

# create LVM on all m2 Disks
MTWODEVGROUP=""
for FOUNDPART in $(fdisk -l | grep -Eo "nvme[0-9]n[0-9]+")
do
    (
    echo o # delete partition
    echo Y # partition number
    echo n # Add a new partition
    echo 1 # partition number
    echo   # Accept default (First sector (34-4458462, default = 262144) or {+-}size{KMGTP})
    echo   # Accept default (Last sector (262144-4458462, default = 4458462) or {+-}size{KMGTP})
    echo   # Accept default (Hex code or GUID (L to show codes, Enter = 8300)
    echo w # Write changes
    echo Y # confirm
    echo Y # confirm
    ) | gdisk /dev/${FOUNDPART}

    # create LVM
    (
    echo y
    ) | pvcreate /dev/${FOUNDPART}p1

    MTWODEVGROUP="$MTWODEVGROUP /dev/${FOUNDPART}p1"
done

MTWODEVGROUP=$(echo $MTWODEVGROUP | sed -i 's/  //')
LVMDEVICEGROUP="$MTWODEVGROUP $LVMDEVICEGROUP"

vgcreate ${ROOTVLNAME}VG $LVMDEVICEGROUP # Combine them into a LVM volume group /dev/mmcblk1p5 /dev/nvme0n1p5 /dev/sda1 /dev/sdb1 /dev/sdc1 ...
# create logical volume
lvcreate -l 100%FREE -n ${ROOTVLNAME}LV ${ROOTVLNAME}VG # Create a logical volume

# create rootfs partition on LVM
(
echo n # Add a new partition
echo 1 # partition number
echo   # Accept default (First sector (34-4458462, default = 262144) or {+-}size{KMGTP})
echo   # Accept default (Last sector (262144-4458462, default = 4458462) or {+-}size{KMGTP})
echo   # Accept default (Hex code or GUID (L to show codes, Enter = 8300)
echo w # Write changes
echo Y # confirm
echo Y # confirm
) | gdisk /dev/mapper/${ROOTVLNAME}VG-${ROOTVLNAME}LV

# restore image directly from xz
FLASHIMGXZ=$(find /rockpi4b-ubuntu-bionic-*-*.img.xz)

#dd if=/dev/zero of=/dev/mmcblk1 bs=128M status=progress
xzcat $FLASHIMGXZ | dd of=/dev/mapper/${ROOTVLNAME}VG-${ROOTVLNAME}LV bs=128M status=progress

# fix LVM GPT 
(
echo x
echo e
echo Y
echo w
echo Y
) | gdisk /dev/mapper/${ROOTVLNAME}VG-${ROOTVLNAME}LV
#/dev/mapper/ExtraSpaceVG-ExtraSpaceLV-part1  2048 241393630 241391583 115.1G Linux filesystem

# resize LVM partition
#lvresize -l +100%FREE /dev/mapper/${ROOTVLNAME}VG-${ROOTVLNAME}LV


# SWAP FILES AND FSTAB
# create 2gb swap file on boot partition (requires boot partition to be in fstab)
#mkdir -p /media/bootpart
#mount /dev/mmcblk1p4 /media/bootpart
#fallocate -l 2G /media/bootpart/swapfile2gb1
#chmod 600 /media/bootpart/swapfile2gb1
#mkswap /media/bootpart/swapfile2gb1


# log partition uuid's
#PARTUUIDEMMCONEFULL=$(blkid | sed -n '/mmcblk0p5/s/.*PARTUUID=\"\([^\"]*\)\".*/\1/p')
#PARTUUIDEMMCZEROFULL=$(blkid | sed -n '/mmcblk1p5/s/.*PARTUUID=\"\([^\"]*\)\".*/\1/p')
#PARTUUIDMTWOZEROFULL=$(blkid | sed -n '/nvme0n1p5/s/.*PARTUUID=\"\([^\"]*\)\".*/\1/p')

#echo "PARTUUID mmcblk0p5: $PARTUUIDEMMCONEFULL" >> /tmp/$FLASHIMGXZ.log
#echo "PARTUUID mmcblk1p5: $PARTUUIDEMMCZEROFULL" >> /tmp/$FLASHIMGXZ.log
#echo "PARTUUID nvme0n1p5: $PARTUUIDMTWOZEROFULL" >> /tmp/$FLASHIMGXZ.log

EDIT: m2 disk part if flashing only m2 is not required, so I deleted it

The infor you are posting is top quality with great scripts, but just some feedback.
Making raid across eMMc and M.2 just hobnails the M.2 to the slower eMMc.
It would be great if Radxa could make a really cheap and really usefull 128/256mb eMMC module as soldering on nand flash for SPI for a purchase is severe and essentially breaks warranty.

I really love the assembled form factor of the RockPi4, I actually like the heatsink, m.2 extender and think its just brilliant when finished, but for Dev and playing the ribbon on the m.2 and the eMMc under the heatsink can be a proper pain in the ass.

@cevap you got any ideas on how to access SD or eMMc without starting to disassemble there prob is but generally I am used just grabbing the Micro SD putting in a reader and flashing whatever I am playing with.

@raxda you guys got any chance of sourcing a 4 port m.2 sata?

you missed this?: Installing images with DD, no need for emmc adapter, run on USB3 or M2 per default

As this is exactly how it is done :slight_smile:

Here you have those many dirty (some unfinished etc… but as a refference you couold look up until I finish disk management stuff)

My M2.ssd did not arrive today, have to check if any close shop to me has any, but if I am unlucky, RAID0 tests postponed to the next week

I am not having much look either you any ideas how to force PCIe gen2 training?

You are right about it and I never said that I want to make raid of m2/eMMC as eMMC is around 2 times slower, it would actually be slower than to run it on m2 only. However, I guess you are not very familiar with lvm’s, as if you have as example 8 port hub with 8 disks connected to it including one eMMC card which actually has for sure some free space as only ~140Mb are used for a boot, leaving you at least 16G free space with smallest eMMC which you then again neither want to use for swap (as it is slower) nor it is big enough to be seen as slow speed archive. As addition, eMMC card is more expesive than m2.ssd of double size which is also faster than eMMC, maybe power usage differs slightly, but nothing that would bring me to use eMMC over m2, at the same time, eMMC fits perfect as boot partition/device, combined with auto boot from SD, its perfect if you broke your system or similar, I would not like if RADXA changes default boot to something else than it currently is (unless :slight_smile: they make it much better, whatever it would be).

Back to LVM and those 8 USB disks. Now we actually have 2 USB3 ports where we could connect additional 8 port USB hub, letting us connect 16 HDD’s over USB Hubs and we still have 2 USB2 Slots free. Now those are usefull if you want to connect old disks (like IDE/SATA) or even additional SD cards which lay around (most have some but no usage for them, now those could be usefull in LVM if they would tend to corrupt more due to SD tech itself

Lets now agree we have 19 disks, where one of them is internal eMMC, 20 if we use also SD card, 22 if we connect 2 SD cards over 2 USB2 ports which are available.

So, we have now 22 disks, lol. How would you create now partitions, how would you manage it etc, etc…

What I simply do is, I create RAID modes (doesnt matter which, who needs backup will not use it stripped, lets say all of them will be RAID0). Now it means I could create 11 RAID0 disks, now again, how would you mount them :slight_smile: if not using LVM? So, to continue, I will actually setup 10 RAID0’s, eMMC and SD would be used with boot partitions and only their free space would be added to LVM.

So, how would it look like

LVM | -r0-r1-…-r10-lvmemmc-lvmsd |

So, I bet with you:

  1. that this :joy: will be blazing fast as LVM itself will be faster than any of those raid’s alone
  2. It is much easier and userfriendly for users if they have 1 disk
  3. Now everything is ready for encrypted disks (just requires now video output for that @RADXA, I will test it, did not for now)

Meaning, that even if I have no RAID0 but only m2 and eMMC, both of them in LVM will not really :slight_smile: slow down your rock, more the opposite, however, those 2 in raid would slow it down as m2 would always need to wait for emmc

LVM is probably an ecumenical matter you any ideas how to force pcie gen2?

Adapt your paths: https://github.com/cevap/rockpi4-bionic/blob/366c77dae2cd6573f867c71c122d25f51c114c6d/usr/bin/third_boot.sh#L86

Already have but seems to do little both dto & dts are set to gen2

what does lspci -vv | grep -E 'PCI bridge|LnkCap tell you?

Nothing

sudo dmesg | grep -E “pcie”

ends with
rockchip-pcie f8000000.pcie: PCIe link training gen1 timeout!
[ 2.173158] rockchip-pcie: probe of f8000000.pcie failed with error -110

Full list is

[    1.489159] of_get_named_gpiod_flags: parsed 'gpio' property of node '/vcc3v3-pcie-regulator[0]' - status (0)
[    1.489201] reg-fixed-voltage vcc3v3-pcie-regulator: Looking up vin-supply from device tree
[    1.489236] vcc3v3_pcie: supplied by vcc3v3_sys
[    1.489697] vcc3v3_pcie: at 3300 mV 
[    1.489857] reg-fixed-voltage vcc3v3-pcie-regulator: vcc3v3_pcie supplying 0uV
[    1.623989] phy phy-pcie-phy.9: Looking up phy-supply from device tree
[    1.623999] phy phy-pcie-phy.9: Looking up phy-supply property in node /pcie-phy failed
[    1.625451] rockchip-pcie f8000000.pcie: GPIO lookup for consumer ep
[    1.625461] rockchip-pcie f8000000.pcie: using device tree for GPIO lookup
[    1.625490] of_get_named_gpiod_flags: parsed 'ep-gpios' property of node '/pcie@f8000000[0]' - status (0)
[    1.625725] rockchip-pcie f8000000.pcie: Looking up vpcie3v3-supply from device tree
[    1.625736] rockchip-pcie f8000000.pcie: Looking up vpcie3v3-supply property in node /pcie@f8000000 failed
[    1.625748] rockchip-pcie f8000000.pcie: no vpcie3v3 regulator found
[    1.626340] rockchip-pcie f8000000.pcie: Looking up vpcie1v8-supply from device tree
[    1.626350] rockchip-pcie f8000000.pcie: Looking up vpcie1v8-supply property in node /pcie@f8000000 failed
[    1.626360] rockchip-pcie f8000000.pcie: no vpcie1v8 regulator found
[    1.626951] rockchip-pcie f8000000.pcie: Looking up vpcie0v9-supply from device tree
[    1.626960] rockchip-pcie f8000000.pcie: Looking up vpcie0v9-supply property in node /pcie@f8000000 failed
[    1.626970] rockchip-pcie f8000000.pcie: no vpcie0v9 regulator found
[    2.172391] rockchip-pcie f8000000.pcie: PCIe link training gen1 timeout!
[    2.173158] rockchip-pcie: probe of f8000000.pcie failed with error -110

did you install latest u-boot and linux-4.4-latest packages? And do you have file hw_intfc.conf in your boot folder? I would assume you did not install all packages, those required are in all lists I previously posted:

# rockpi4 latest kernel and bootloader
apt-get install -y linux-base
apt-get install -y linux-4.4-latest
apt-get install -y rockpi4b-rk-u-boot-latest

EDIT: run please uname -a and post which kernel is used

EDIT2: output of previous command should show you this:

$ lspci -vv | grep -E 'PCI bridge|LnkCap'
00:00.0 PCI bridge: Fuzhou Rockchip Electronics Co., Ltd Device 0100 (prog-if 00 [Normal decode])
                LnkCap: Port #0, Speed 2.5GT/s, Width x4, ASPM L1, Exit Latency L0s <256ns, L1 <8us
                LnkCap: Port #0, Speed 8GT/s, Width x4, ASPM L1, Exit Latency L0s unlimited, L1 <64us

Linux linux 4.4.154-83-rockchip-00023-gae7a309 #2 SMP Fri Apr 12 20:04:24 CST 2019 aarch64 aarch64 aarch64 GNU/Linux

lspci -vv | grep -E 'PCI bridge|LnkCap'

Like I say nothing

and do you have hw_intfc.conf in your boot?

If you did install all packages and you are using latest kernel, then you must have pcie working too. What could happen is that one boot folder boots but the other one gets updated, however, by my installation method this is not the case and as your kernel is latest, I would say you either forgot something or you changed manually something and made it non working.

If you have hw_intfc.conf, then you can enable gen2, if not, you still could on the old way, but really, thats not the path you should take.

I made 100’s of installs with my script and manually, pci gen2 works

Yeah its there hw_intfc.conf in boot, but nope nothing

Now search for line:

#intfc:dtoverlay=pcie-gen2

and unmark it:

intfc:dtoverlay=pcie-gen2

reboot, thats it

if your boot folder is properly mounted, you can run:

sed -i "s/#intfc:dtoverlay=pcie-gen2/intfc:dtoverlay=pcie-gen2/" /boot/hw_intfc.conf

to unmark it with sed, as those who use scripts will appreaciate this method more than to change by hand

Its already done