mbox series

[0/9] Nokia RX-51: Small cleanups and UBI boot test case

Message ID 20220904012906.17718-1-pali@kernel.org
Headers show
Series Nokia RX-51: Small cleanups and UBI boot test case | expand

Message

Pali Rohár Sept. 4, 2022, 1:28 a.m. UTC
Do various small fixup/cleanups and extend test script to boot kernel
image from UBI volume. This test verifies that U-Boot UBI implementation
is working and U-Boot can read volume with bootable kernel code
correctly. And therefore CI prevents UBI breakage.

Note that U-Boot UBIFS code on ARM is currently somehow broken and
trying to mount UBIFS from UBI volume fails :-( I have already tried to
debug this issue but I have no idea why it is failing. Function
check_lpt_crc in unpack_ltab is failing. Volume is for sure correct and
valid because Linux kernel can successfully mount it. And to make it
more suspicious, U-Boot UBIFS is working fine on big endian powerpc
platform. So UBIFS issue is probably endian or arch specific.
(This is UBIFS related, not UBI related.)

Pali Rohár (9):
  Nokia RX-51: Remove label copy_kernel_start from lowlevel_init.S
  Nokia RX-51: Do not clear unknown memory in lowlevel_init.S
  Nokia RX-51: Set default SYS_LOAD_ADDR to 0x80008000
  Nokia RX-51: Change UBIFS volume size to 1870 LEBs in test script
  Nokia RX-51: Call bootm in test script only when image is valid
  Nokia RX-51: Fix documentation how to enable UBI support
  Nokia RX-51: Do not set useless ARCH= in test script
  Nokia RX-51: Add comment describing kernel image type into test script
  Nokia RX-51: Add booting from UBI into test script

 board/nokia/rx51/lowlevel_init.S |  7 +--
 configs/nokia_rx51_defconfig     |  2 +-
 doc/board/nokia/rx51.rst         |  3 +-
 test/nokia_rx51_test.sh          | 97 +++++++++++++++++++++++++-------
 4 files changed, 82 insertions(+), 27 deletions(-)

Comments

Tony Dinh Sept. 4, 2022, 3:01 a.m. UTC | #1
Hi Pali,

On Sat, Sep 3, 2022 at 6:29 PM Pali Rohár <pali@kernel.org> wrote:
>
> Do various small fixup/cleanups and extend test script to boot kernel
> image from UBI volume. This test verifies that U-Boot UBI implementation
> is working and U-Boot can read volume with bootable kernel code
> correctly. And therefore CI prevents UBI breakage.
>
> Note that U-Boot UBIFS code on ARM is currently somehow broken and
> trying to mount UBIFS from UBI volume fails :-( I have already tried to
> debug this issue but I have no idea why it is failing.

I've recently implemented UBI distro boot on a pair of Kirkwood boards
(Pogo V4 and NSA310s) successfully. I created the UBI partition and
formatted it in Debian 11.x, Linux kernel 5.19.x. I could let the
u-boot distro boot scan the UBI partition to find the boot script
boot.scr. And also mount it manually to look at the file system.

An observation: I cannot mount OpenWrt rootfs in u-boot, since it is
an UBIFS volume overlay on squashfs. But creating my own UBIFS volume
allowed me to mount it in the u-boot command line. I think squashfs is
incomplete in u-boot, at the moment.

Best,
Tony


>  Function
> check_lpt_crc in unpack_ltab is failing. Volume is for sure correct and
> valid because Linux kernel can successfully mount it. And to make it
> more suspicious, U-Boot UBIFS is working fine on big endian powerpc
> platform. So UBIFS issue is probably endian or arch specific.
> (This is UBIFS related, not UBI related.)
>
> Pali Rohár (9):
>   Nokia RX-51: Remove label copy_kernel_start from lowlevel_init.S
>   Nokia RX-51: Do not clear unknown memory in lowlevel_init.S
>   Nokia RX-51: Set default SYS_LOAD_ADDR to 0x80008000
>   Nokia RX-51: Change UBIFS volume size to 1870 LEBs in test script
>   Nokia RX-51: Call bootm in test script only when image is valid
>   Nokia RX-51: Fix documentation how to enable UBI support
>   Nokia RX-51: Do not set useless ARCH= in test script
>   Nokia RX-51: Add comment describing kernel image type into test script
>   Nokia RX-51: Add booting from UBI into test script
>
>  board/nokia/rx51/lowlevel_init.S |  7 +--
>  configs/nokia_rx51_defconfig     |  2 +-
>  doc/board/nokia/rx51.rst         |  3 +-
>  test/nokia_rx51_test.sh          | 97 +++++++++++++++++++++++++-------
>  4 files changed, 82 insertions(+), 27 deletions(-)
>
> --
> 2.20.1
>
Pali Rohár Sept. 4, 2022, 9:37 a.m. UTC | #2
On Saturday 03 September 2022 20:01:45 Tony Dinh wrote:
> Hi Pali,
> 
> On Sat, Sep 3, 2022 at 6:29 PM Pali Rohár <pali@kernel.org> wrote:
> >
> > Do various small fixup/cleanups and extend test script to boot kernel
> > image from UBI volume. This test verifies that U-Boot UBI implementation
> > is working and U-Boot can read volume with bootable kernel code
> > correctly. And therefore CI prevents UBI breakage.
> >
> > Note that U-Boot UBIFS code on ARM is currently somehow broken and
> > trying to mount UBIFS from UBI volume fails :-( I have already tried to
> > debug this issue but I have no idea why it is failing.
> 
> I've recently implemented UBI distro boot on a pair of Kirkwood boards
> (Pogo V4 and NSA310s) successfully. I created the UBI partition and
> formatted it in Debian 11.x, Linux kernel 5.19.x. I could let the
> u-boot distro boot scan the UBI partition to find the boot script
> boot.scr. And also mount it manually to look at the file system.

Hello! I think you mean UBIFS on UBI, right?

> An observation: I cannot mount OpenWrt rootfs in u-boot, since it is
> an UBIFS volume overlay on squashfs. But creating my own UBIFS volume
> allowed me to mount it in the u-boot command line. I think squashfs is
> incomplete in u-boot, at the moment.

UBIFS on squashfs? This looks strange. AFAIK UBIFS (also on linux) works
only on UBI. I guess you could have squashfs on UBI, but on linux this
requires mtdblock, hence it is squashfs on mtdblock on UBI.

> Best,
> Tony
> 
> 
> >  Function
> > check_lpt_crc in unpack_ltab is failing. Volume is for sure correct and
> > valid because Linux kernel can successfully mount it. And to make it
> > more suspicious, U-Boot UBIFS is working fine on big endian powerpc
> > platform. So UBIFS issue is probably endian or arch specific.
> > (This is UBIFS related, not UBI related.)
> >
> > Pali Rohár (9):
> >   Nokia RX-51: Remove label copy_kernel_start from lowlevel_init.S
> >   Nokia RX-51: Do not clear unknown memory in lowlevel_init.S
> >   Nokia RX-51: Set default SYS_LOAD_ADDR to 0x80008000
> >   Nokia RX-51: Change UBIFS volume size to 1870 LEBs in test script
> >   Nokia RX-51: Call bootm in test script only when image is valid
> >   Nokia RX-51: Fix documentation how to enable UBI support
> >   Nokia RX-51: Do not set useless ARCH= in test script
> >   Nokia RX-51: Add comment describing kernel image type into test script
> >   Nokia RX-51: Add booting from UBI into test script
> >
> >  board/nokia/rx51/lowlevel_init.S |  7 +--
> >  configs/nokia_rx51_defconfig     |  2 +-
> >  doc/board/nokia/rx51.rst         |  3 +-
> >  test/nokia_rx51_test.sh          | 97 +++++++++++++++++++++++++-------
> >  4 files changed, 82 insertions(+), 27 deletions(-)
> >
> > --
> > 2.20.1
> >
Tony Dinh Sept. 4, 2022, 7:28 p.m. UTC | #3
Hi Pali,

On Sun, Sep 4, 2022 at 2:37 AM Pali Rohár <pali@kernel.org> wrote:
>
> On Saturday 03 September 2022 20:01:45 Tony Dinh wrote:
> > Hi Pali,
> >
> > On Sat, Sep 3, 2022 at 6:29 PM Pali Rohár <pali@kernel.org> wrote:
> > >
> > > Do various small fixup/cleanups and extend test script to boot kernel
> > > image from UBI volume. This test verifies that U-Boot UBI implementation
> > > is working and U-Boot can read volume with bootable kernel code
> > > correctly. And therefore CI prevents UBI breakage.
> > >
> > > Note that U-Boot UBIFS code on ARM is currently somehow broken and
> > > trying to mount UBIFS from UBI volume fails :-( I have already tried to
> > > debug this issue but I have no idea why it is failing.
> >
> > I've recently implemented UBI distro boot on a pair of Kirkwood boards
> > (Pogo V4 and NSA310s) successfully. I created the UBI partition and
> > formatted it in Debian 11.x, Linux kernel 5.19.x. I could let the
> > u-boot distro boot scan the UBI partition to find the boot script
> > boot.scr. And also mount it manually to look at the file system.
>
> Hello! I think you mean UBIFS on UBI, right?

Yes. UBIFS on UBI.

>
> > An observation: I cannot mount OpenWrt rootfs in u-boot, since it is
> > an UBIFS volume overlay on squashfs. But creating my own UBIFS volume
> > allowed me to mount it in the u-boot command line. I think squashfs is
> > incomplete in u-boot, at the moment.
>
> UBIFS on squashfs? This looks strange. AFAIK UBIFS (also on linux) works
> only on UBI. I guess you could have squashfs on UBI, but on linux this
> requires mtdblock, hence it is squashfs on mtdblock on UBI.

I meant that (the rootfs) is a squashfs inside an UBIFS volume. And
the system running with another UBIFS volume overlaid on top of that.

Best,
Tony

>
> > Best,
> > Tony
> >
> >
> > >  Function
> > > check_lpt_crc in unpack_ltab is failing. Volume is for sure correct and
> > > valid because Linux kernel can successfully mount it. And to make it
> > > more suspicious, U-Boot UBIFS is working fine on big endian powerpc
> > > platform. So UBIFS issue is probably endian or arch specific.
> > > (This is UBIFS related, not UBI related.)
> > >
> > > Pali Rohár (9):
> > >   Nokia RX-51: Remove label copy_kernel_start from lowlevel_init.S
> > >   Nokia RX-51: Do not clear unknown memory in lowlevel_init.S
> > >   Nokia RX-51: Set default SYS_LOAD_ADDR to 0x80008000
> > >   Nokia RX-51: Change UBIFS volume size to 1870 LEBs in test script
> > >   Nokia RX-51: Call bootm in test script only when image is valid
> > >   Nokia RX-51: Fix documentation how to enable UBI support
> > >   Nokia RX-51: Do not set useless ARCH= in test script
> > >   Nokia RX-51: Add comment describing kernel image type into test script
> > >   Nokia RX-51: Add booting from UBI into test script
> > >
> > >  board/nokia/rx51/lowlevel_init.S |  7 +--
> > >  configs/nokia_rx51_defconfig     |  2 +-
> > >  doc/board/nokia/rx51.rst         |  3 +-
> > >  test/nokia_rx51_test.sh          | 97 +++++++++++++++++++++++++-------
> > >  4 files changed, 82 insertions(+), 27 deletions(-)
> > >
> > > --
> > > 2.20.1
> > >
Tony Dinh Sept. 4, 2022, 7:56 p.m. UTC | #4
On Sun, Sep 4, 2022 at 12:28 PM Tony Dinh <mibodhi@gmail.com> wrote:
>
> Hi Pali,
>
> On Sun, Sep 4, 2022 at 2:37 AM Pali Rohár <pali@kernel.org> wrote:
> >
> > On Saturday 03 September 2022 20:01:45 Tony Dinh wrote:
> > > Hi Pali,
> > >
> > > On Sat, Sep 3, 2022 at 6:29 PM Pali Rohár <pali@kernel.org> wrote:
> > > >
> > > > Do various small fixup/cleanups and extend test script to boot kernel
> > > > image from UBI volume. This test verifies that U-Boot UBI implementation
> > > > is working and U-Boot can read volume with bootable kernel code
> > > > correctly. And therefore CI prevents UBI breakage.
> > > >
> > > > Note that U-Boot UBIFS code on ARM is currently somehow broken and
> > > > trying to mount UBIFS from UBI volume fails :-( I have already tried to
> > > > debug this issue but I have no idea why it is failing.
> > >
> > > I've recently implemented UBI distro boot on a pair of Kirkwood boards
> > > (Pogo V4 and NSA310s) successfully. I created the UBI partition and
> > > formatted it in Debian 11.x, Linux kernel 5.19.x. I could let the
> > > u-boot distro boot scan the UBI partition to find the boot script
> > > boot.scr. And also mount it manually to look at the file system.
> >
> > Hello! I think you mean UBIFS on UBI, right?
>
> Yes. UBIFS on UBI.
>
> >
> > > An observation: I cannot mount OpenWrt rootfs in u-boot, since it is
> > > an UBIFS volume overlay on squashfs. But creating my own UBIFS volume
> > > allowed me to mount it in the u-boot command line. I think squashfs is
> > > incomplete in u-boot, at the moment.
> >
> > UBIFS on squashfs? This looks strange. AFAIK UBIFS (also on linux) works
> > only on UBI. I guess you could have squashfs on UBI, but on linux this
> > requires mtdblock, hence it is squashfs on mtdblock on UBI.
>
> I meant that (the rootfs) is a squashfs inside an UBIFS volume. And
> the system running with another UBIFS volume overlaid on top of that.

I should say "UBI volume" above.

>
> Best,
> Tony
>
> >
> > > Best,
> > > Tony
> > >
> > >
> > > >  Function
> > > > check_lpt_crc in unpack_ltab is failing. Volume is for sure correct and
> > > > valid because Linux kernel can successfully mount it. And to make it
> > > > more suspicious, U-Boot UBIFS is working fine on big endian powerpc
> > > > platform. So UBIFS issue is probably endian or arch specific.
> > > > (This is UBIFS related, not UBI related.)
> > > >
> > > > Pali Rohár (9):
> > > >   Nokia RX-51: Remove label copy_kernel_start from lowlevel_init.S
> > > >   Nokia RX-51: Do not clear unknown memory in lowlevel_init.S
> > > >   Nokia RX-51: Set default SYS_LOAD_ADDR to 0x80008000
> > > >   Nokia RX-51: Change UBIFS volume size to 1870 LEBs in test script
> > > >   Nokia RX-51: Call bootm in test script only when image is valid
> > > >   Nokia RX-51: Fix documentation how to enable UBI support
> > > >   Nokia RX-51: Do not set useless ARCH= in test script
> > > >   Nokia RX-51: Add comment describing kernel image type into test script
> > > >   Nokia RX-51: Add booting from UBI into test script
> > > >
> > > >  board/nokia/rx51/lowlevel_init.S |  7 +--
> > > >  configs/nokia_rx51_defconfig     |  2 +-
> > > >  doc/board/nokia/rx51.rst         |  3 +-
> > > >  test/nokia_rx51_test.sh          | 97 +++++++++++++++++++++++++-------
> > > >  4 files changed, 82 insertions(+), 27 deletions(-)
> > > >
> > > > --
> > > > 2.20.1
> > > >
Daniel Golle Sept. 4, 2022, 9:58 p.m. UTC | #5
On Sun, Sep 04, 2022 at 12:28:24PM -0700, Tony Dinh wrote:
> Hi Pali,
> 
> On Sun, Sep 4, 2022 at 2:37 AM Pali Rohár <pali@kernel.org> wrote:
> >
> > On Saturday 03 September 2022 20:01:45 Tony Dinh wrote:
> > > Hi Pali,
> > >
> > > On Sat, Sep 3, 2022 at 6:29 PM Pali Rohár <pali@kernel.org> wrote:
> > > >
> > > > Do various small fixup/cleanups and extend test script to boot kernel
> > > > image from UBI volume. This test verifies that U-Boot UBI implementation
> > > > is working and U-Boot can read volume with bootable kernel code
> > > > correctly. And therefore CI prevents UBI breakage.
> > > >
> > > > Note that U-Boot UBIFS code on ARM is currently somehow broken and
> > > > trying to mount UBIFS from UBI volume fails :-( I have already tried to
> > > > debug this issue but I have no idea why it is failing.
> > >
> > > I've recently implemented UBI distro boot on a pair of Kirkwood boards
> > > (Pogo V4 and NSA310s) successfully. I created the UBI partition and
> > > formatted it in Debian 11.x, Linux kernel 5.19.x. I could let the
> > > u-boot distro boot scan the UBI partition to find the boot script
> > > boot.scr. And also mount it manually to look at the file system.
> >
> > Hello! I think you mean UBIFS on UBI, right?
> 
> Yes. UBIFS on UBI.
> 
> >
> > > An observation: I cannot mount OpenWrt rootfs in u-boot, since it is
> > > an UBIFS volume overlay on squashfs. But creating my own UBIFS volume
> > > allowed me to mount it in the u-boot command line. I think squashfs is
> > > incomplete in u-boot, at the moment.
> >
> > UBIFS on squashfs? This looks strange. AFAIK UBIFS (also on linux) works
> > only on UBI. I guess you could have squashfs on UBI, but on linux this
> > requires mtdblock, hence it is squashfs on mtdblock on UBI.
> 
> I meant that (the rootfs) is a squashfs inside an UBIFS volume. And
> the system running with another UBIFS volume overlaid on top of that.

Just to clarify: OpenWrt uses squashfs in UBI volumes for the compressed
rootfs. In Linux, ubiblock is used to mount them.

We also usually don't store the kernel in a filesystem but just use a
bare UBI volume to directly store the uImage.FIT to be booted, for both
simplicity and robustness reasons.
On devices with recent enough U-Boot we can use a 'filesystem'-type
sub-image of a uImage.FIT for squashfs and mount that in Linux.

> 
> Best,
> Tony
> 
> >
> > > Best,
> > > Tony
> > >
> > >
> > > >  Function
> > > > check_lpt_crc in unpack_ltab is failing. Volume is for sure correct and
> > > > valid because Linux kernel can successfully mount it. And to make it
> > > > more suspicious, U-Boot UBIFS is working fine on big endian powerpc
> > > > platform. So UBIFS issue is probably endian or arch specific.
> > > > (This is UBIFS related, not UBI related.)
> > > >
> > > > Pali Rohár (9):
> > > >   Nokia RX-51: Remove label copy_kernel_start from lowlevel_init.S
> > > >   Nokia RX-51: Do not clear unknown memory in lowlevel_init.S
> > > >   Nokia RX-51: Set default SYS_LOAD_ADDR to 0x80008000
> > > >   Nokia RX-51: Change UBIFS volume size to 1870 LEBs in test script
> > > >   Nokia RX-51: Call bootm in test script only when image is valid
> > > >   Nokia RX-51: Fix documentation how to enable UBI support
> > > >   Nokia RX-51: Do not set useless ARCH= in test script
> > > >   Nokia RX-51: Add comment describing kernel image type into test script
> > > >   Nokia RX-51: Add booting from UBI into test script
> > > >
> > > >  board/nokia/rx51/lowlevel_init.S |  7 +--
> > > >  configs/nokia_rx51_defconfig     |  2 +-
> > > >  doc/board/nokia/rx51.rst         |  3 +-
> > > >  test/nokia_rx51_test.sh          | 97 +++++++++++++++++++++++++-------
> > > >  4 files changed, 82 insertions(+), 27 deletions(-)
> > > >
> > > > --
> > > > 2.20.1
> > > >
Pali Rohár Sept. 4, 2022, 10:10 p.m. UTC | #6
On Sunday 04 September 2022 22:58:19 Daniel Golle wrote:
> On Sun, Sep 04, 2022 at 12:28:24PM -0700, Tony Dinh wrote:
> > Hi Pali,
> > 
> > On Sun, Sep 4, 2022 at 2:37 AM Pali Rohár <pali@kernel.org> wrote:
> > >
> > > On Saturday 03 September 2022 20:01:45 Tony Dinh wrote:
> > > > Hi Pali,
> > > >
> > > > On Sat, Sep 3, 2022 at 6:29 PM Pali Rohár <pali@kernel.org> wrote:
> > > > >
> > > > > Do various small fixup/cleanups and extend test script to boot kernel
> > > > > image from UBI volume. This test verifies that U-Boot UBI implementation
> > > > > is working and U-Boot can read volume with bootable kernel code
> > > > > correctly. And therefore CI prevents UBI breakage.
> > > > >
> > > > > Note that U-Boot UBIFS code on ARM is currently somehow broken and
> > > > > trying to mount UBIFS from UBI volume fails :-( I have already tried to
> > > > > debug this issue but I have no idea why it is failing.
> > > >
> > > > I've recently implemented UBI distro boot on a pair of Kirkwood boards
> > > > (Pogo V4 and NSA310s) successfully. I created the UBI partition and
> > > > formatted it in Debian 11.x, Linux kernel 5.19.x. I could let the
> > > > u-boot distro boot scan the UBI partition to find the boot script
> > > > boot.scr. And also mount it manually to look at the file system.
> > >
> > > Hello! I think you mean UBIFS on UBI, right?
> > 
> > Yes. UBIFS on UBI.
> > 
> > >
> > > > An observation: I cannot mount OpenWrt rootfs in u-boot, since it is
> > > > an UBIFS volume overlay on squashfs. But creating my own UBIFS volume
> > > > allowed me to mount it in the u-boot command line. I think squashfs is
> > > > incomplete in u-boot, at the moment.
> > >
> > > UBIFS on squashfs? This looks strange. AFAIK UBIFS (also on linux) works
> > > only on UBI. I guess you could have squashfs on UBI, but on linux this
> > > requires mtdblock, hence it is squashfs on mtdblock on UBI.
> > 
> > I meant that (the rootfs) is a squashfs inside an UBIFS volume. And
> > the system running with another UBIFS volume overlaid on top of that.
> 
> Just to clarify: OpenWrt uses squashfs in UBI volumes for the compressed
> rootfs. In Linux, ubiblock is used to mount them.

That is what I thought. squashfs on ubiblock. IIRC U-Boot does not
implement neither mtdblock (block device on mtd) nor ubiblock (block
device on top of ubi volume). So mounting squashfs (which is block based
filesystem) from ubi volume does not work in u-boot.

I think implementation should not be such hard, this sounds like and
interesting exercise.

But I'm more interested to figure out why UBIFS does not want to work on
ARM Omap3 Nokia N900, but works fine on PowerPC Freescale P2020....

> We also usually don't store the kernel in a filesystem but just use a
> bare UBI volume to directly store the uImage.FIT to be booted, for both
> simplicity and robustness reasons.
> On devices with recent enough U-Boot we can use a 'filesystem'-type
> sub-image of a uImage.FIT for squashfs and mount that in Linux.
> 
> > 
> > Best,
> > Tony
> > 
> > >
> > > > Best,
> > > > Tony
> > > >
> > > >
> > > > >  Function
> > > > > check_lpt_crc in unpack_ltab is failing. Volume is for sure correct and
> > > > > valid because Linux kernel can successfully mount it. And to make it
> > > > > more suspicious, U-Boot UBIFS is working fine on big endian powerpc
> > > > > platform. So UBIFS issue is probably endian or arch specific.
> > > > > (This is UBIFS related, not UBI related.)
> > > > >
> > > > > Pali Rohár (9):
> > > > >   Nokia RX-51: Remove label copy_kernel_start from lowlevel_init.S
> > > > >   Nokia RX-51: Do not clear unknown memory in lowlevel_init.S
> > > > >   Nokia RX-51: Set default SYS_LOAD_ADDR to 0x80008000
> > > > >   Nokia RX-51: Change UBIFS volume size to 1870 LEBs in test script
> > > > >   Nokia RX-51: Call bootm in test script only when image is valid
> > > > >   Nokia RX-51: Fix documentation how to enable UBI support
> > > > >   Nokia RX-51: Do not set useless ARCH= in test script
> > > > >   Nokia RX-51: Add comment describing kernel image type into test script
> > > > >   Nokia RX-51: Add booting from UBI into test script
> > > > >
> > > > >  board/nokia/rx51/lowlevel_init.S |  7 +--
> > > > >  configs/nokia_rx51_defconfig     |  2 +-
> > > > >  doc/board/nokia/rx51.rst         |  3 +-
> > > > >  test/nokia_rx51_test.sh          | 97 +++++++++++++++++++++++++-------
> > > > >  4 files changed, 82 insertions(+), 27 deletions(-)
> > > > >
> > > > > --
> > > > > 2.20.1
> > > > >
Tony Dinh Sept. 5, 2022, 9:35 p.m. UTC | #7
Thanks Damiel!

On Sun, Sep 4, 2022 at 3:10 PM Pali Rohár <pali@kernel.org> wrote:
>
> On Sunday 04 September 2022 22:58:19 Daniel Golle wrote:
> > On Sun, Sep 04, 2022 at 12:28:24PM -0700, Tony Dinh wrote:
> > > Hi Pali,
> > >
> > > On Sun, Sep 4, 2022 at 2:37 AM Pali Rohár <pali@kernel.org> wrote:
> > > >
> > > > On Saturday 03 September 2022 20:01:45 Tony Dinh wrote:
> > > > > Hi Pali,
> > > > >
> > > > > On Sat, Sep 3, 2022 at 6:29 PM Pali Rohár <pali@kernel.org> wrote:
> > > > > >
> > > > > > Do various small fixup/cleanups and extend test script to boot kernel
> > > > > > image from UBI volume. This test verifies that U-Boot UBI implementation
> > > > > > is working and U-Boot can read volume with bootable kernel code
> > > > > > correctly. And therefore CI prevents UBI breakage.
> > > > > >
> > > > > > Note that U-Boot UBIFS code on ARM is currently somehow broken and
> > > > > > trying to mount UBIFS from UBI volume fails :-( I have already tried to
> > > > > > debug this issue but I have no idea why it is failing.
> > > > >
> > > > > I've recently implemented UBI distro boot on a pair of Kirkwood boards
> > > > > (Pogo V4 and NSA310s) successfully. I created the UBI partition and
> > > > > formatted it in Debian 11.x, Linux kernel 5.19.x. I could let the
> > > > > u-boot distro boot scan the UBI partition to find the boot script
> > > > > boot.scr. And also mount it manually to look at the file system.
> > > >
> > > > Hello! I think you mean UBIFS on UBI, right?
> > >
> > > Yes. UBIFS on UBI.
> > >
> > > >
> > > > > An observation: I cannot mount OpenWrt rootfs in u-boot, since it is
> > > > > an UBIFS volume overlay on squashfs. But creating my own UBIFS volume
> > > > > allowed me to mount it in the u-boot command line. I think squashfs is
> > > > > incomplete in u-boot, at the moment.
> > > >
> > > > UBIFS on squashfs? This looks strange. AFAIK UBIFS (also on linux) works
> > > > only on UBI. I guess you could have squashfs on UBI, but on linux this
> > > > requires mtdblock, hence it is squashfs on mtdblock on UBI.
> > >
> > > I meant that (the rootfs) is a squashfs inside an UBIFS volume. And
> > > the system running with another UBIFS volume overlaid on top of that.
> >
> > Just to clarify: OpenWrt uses squashfs in UBI volumes for the compressed
> > rootfs. In Linux, ubiblock is used to mount them.
>
> That is what I thought. squashfs on ubiblock. IIRC U-Boot does not
> implement neither mtdblock (block device on mtd) nor ubiblock (block
> device on top of ubi volume). So mounting squashfs (which is block based
> filesystem) from ubi volume does not work in u-boot.
>
> I think implementation should not be such hard, this sounds like and
> interesting exercise.
>
> But I'm more interested to figure out why UBIFS does not want to work on
> ARM Omap3 Nokia N900, but works fine on PowerPC Freescale P2020....
>
> > We also usually don't store the kernel in a filesystem but just use a
> > bare UBI volume to directly store the uImage.FIT to be booted, for both
> > simplicity and robustness reasons.
> > On devices with recent enough U-Boot we can use a 'filesystem'-type
> > sub-image of a uImage.FIT for squashfs and mount that in Linux.
> >
> > >
> > > Best,
> > > Tony
> > >
> > > >
> > > > > Best,
> > > > > Tony
> > > > >
> > > > >
> > > > > >  Function
> > > > > > check_lpt_crc in unpack_ltab is failing. Volume is for sure correct and
> > > > > > valid because Linux kernel can successfully mount it. And to make it
> > > > > > more suspicious, U-Boot UBIFS is working fine on big endian powerpc
> > > > > > platform. So UBIFS issue is probably endian or arch specific.
> > > > > > (This is UBIFS related, not UBI related.)
> > > > > >
> > > > > > Pali Rohár (9):
> > > > > >   Nokia RX-51: Remove label copy_kernel_start from lowlevel_init.S
> > > > > >   Nokia RX-51: Do not clear unknown memory in lowlevel_init.S
> > > > > >   Nokia RX-51: Set default SYS_LOAD_ADDR to 0x80008000
> > > > > >   Nokia RX-51: Change UBIFS volume size to 1870 LEBs in test script
> > > > > >   Nokia RX-51: Call bootm in test script only when image is valid
> > > > > >   Nokia RX-51: Fix documentation how to enable UBI support
> > > > > >   Nokia RX-51: Do not set useless ARCH= in test script
> > > > > >   Nokia RX-51: Add comment describing kernel image type into test script
> > > > > >   Nokia RX-51: Add booting from UBI into test script
> > > > > >
> > > > > >  board/nokia/rx51/lowlevel_init.S |  7 +--
> > > > > >  configs/nokia_rx51_defconfig     |  2 +-
> > > > > >  doc/board/nokia/rx51.rst         |  3 +-
> > > > > >  test/nokia_rx51_test.sh          | 97 +++++++++++++++++++++++++-------
> > > > > >  4 files changed, 82 insertions(+), 27 deletions(-)
> > > > > >
> > > > > > --
> > > > > > 2.20.1
> > > > > >
Alexander Dahl Sept. 19, 2022, 11:12 a.m. UTC | #8
Hello Pali,

Am Sun, Sep 04, 2022 at 03:28:57AM +0200 schrieb Pali Rohár:
> Do various small fixup/cleanups and extend test script to boot kernel
> image from UBI volume. This test verifies that U-Boot UBI implementation
> is working and U-Boot can read volume with bootable kernel code
> correctly. And therefore CI prevents UBI breakage.
> 
> Note that U-Boot UBIFS code on ARM is currently somehow broken and
> trying to mount UBIFS from UBI volume fails :-( I have already tried to
> debug this issue but I have no idea why it is failing. Function
> check_lpt_crc in unpack_ltab is failing. Volume is for sure correct and
> valid because Linux kernel can successfully mount it. And to make it
> more suspicious, U-Boot UBIFS is working fine on big endian powerpc
> platform. So UBIFS issue is probably endian or arch specific.
> (This is UBIFS related, not UBI related.)

I had some trouble with UBIFS volumes created by Linux not mountable
by U-Boot myself recently.  Problem was Linux gained zstd compression
support for UBIFS with version 5.3 and that was made default with
kernel 5.13.  U-Boot does not support zstd compression at least up to
version 2022.04 (did not try later ones), and simply refuses to mount
those volumes.  The error message however was different than yours,
but maybe you get an idea what might be wrong.  I would certainly
check with what features the UBIFS is created and if U-Boot supports
that.

HTH & Greets
Alex

> 
> Pali Rohár (9):
>   Nokia RX-51: Remove label copy_kernel_start from lowlevel_init.S
>   Nokia RX-51: Do not clear unknown memory in lowlevel_init.S
>   Nokia RX-51: Set default SYS_LOAD_ADDR to 0x80008000
>   Nokia RX-51: Change UBIFS volume size to 1870 LEBs in test script
>   Nokia RX-51: Call bootm in test script only when image is valid
>   Nokia RX-51: Fix documentation how to enable UBI support
>   Nokia RX-51: Do not set useless ARCH= in test script
>   Nokia RX-51: Add comment describing kernel image type into test script
>   Nokia RX-51: Add booting from UBI into test script
> 
>  board/nokia/rx51/lowlevel_init.S |  7 +--
>  configs/nokia_rx51_defconfig     |  2 +-
>  doc/board/nokia/rx51.rst         |  3 +-
>  test/nokia_rx51_test.sh          | 97 +++++++++++++++++++++++++-------
>  4 files changed, 82 insertions(+), 27 deletions(-)
> 
> -- 
> 2.20.1
>
Pali Rohár Sept. 19, 2022, 11:23 a.m. UTC | #9
On Monday 19 September 2022 13:12:41 Alexander Dahl wrote:
> Hello Pali,
> 
> Am Sun, Sep 04, 2022 at 03:28:57AM +0200 schrieb Pali Rohár:
> > Do various small fixup/cleanups and extend test script to boot kernel
> > image from UBI volume. This test verifies that U-Boot UBI implementation
> > is working and U-Boot can read volume with bootable kernel code
> > correctly. And therefore CI prevents UBI breakage.
> > 
> > Note that U-Boot UBIFS code on ARM is currently somehow broken and
> > trying to mount UBIFS from UBI volume fails :-( I have already tried to
> > debug this issue but I have no idea why it is failing. Function
> > check_lpt_crc in unpack_ltab is failing. Volume is for sure correct and
> > valid because Linux kernel can successfully mount it. And to make it
> > more suspicious, U-Boot UBIFS is working fine on big endian powerpc
> > platform. So UBIFS issue is probably endian or arch specific.
> > (This is UBIFS related, not UBI related.)
> 
> I had some trouble with UBIFS volumes created by Linux not mountable
> by U-Boot myself recently.  Problem was Linux gained zstd compression
> support for UBIFS with version 5.3 and that was made default with
> kernel 5.13.  U-Boot does not support zstd compression at least up to
> version 2022.04 (did not try later ones), and simply refuses to mount
> those volumes.  The error message however was different than yours,
> but maybe you get an idea what might be wrong.  I would certainly
> check with what features the UBIFS is created and if U-Boot supports
> that.

Hello! The issue is not with zstd compression, I'm sure as I'm
generating it without it. Plus it is working fine with old 2.6.28
kernel, which does not have any zstd support. The issue is with parsing
UBIFS LPT, it looks like that U-Boot is trying to read it from wrong
position or maybe wrong LEB. My another idea is that issue could be in
u-boot onenand driver used on n900 and in qemu. Maybe it is possible
that 'mtd' and 'ubi' commands do not trigger this issue and hence
reading it working fine, but is triggered by ubifs code and ubifs
reading fails. On powerpc platform where ubifs is working fine is
present freescale nand controller / driver, not samsung/onenand.

> HTH & Greets
> Alex
> 
> > 
> > Pali Rohár (9):
> >   Nokia RX-51: Remove label copy_kernel_start from lowlevel_init.S
> >   Nokia RX-51: Do not clear unknown memory in lowlevel_init.S
> >   Nokia RX-51: Set default SYS_LOAD_ADDR to 0x80008000
> >   Nokia RX-51: Change UBIFS volume size to 1870 LEBs in test script
> >   Nokia RX-51: Call bootm in test script only when image is valid
> >   Nokia RX-51: Fix documentation how to enable UBI support
> >   Nokia RX-51: Do not set useless ARCH= in test script
> >   Nokia RX-51: Add comment describing kernel image type into test script
> >   Nokia RX-51: Add booting from UBI into test script
> > 
> >  board/nokia/rx51/lowlevel_init.S |  7 +--
> >  configs/nokia_rx51_defconfig     |  2 +-
> >  doc/board/nokia/rx51.rst         |  3 +-
> >  test/nokia_rx51_test.sh          | 97 +++++++++++++++++++++++++-------
> >  4 files changed, 82 insertions(+), 27 deletions(-)
> > 
> > -- 
> > 2.20.1
> >