Enable UBI support for a platform

Deepak Kodihalli dkodihal at linux.vnet.ibm.com
Fri Sep 11 18:36:04 AEST 2020


Hi Jiandi,

On 09/09/20 10:00 pm, Jiandi An wrote:
>> On 09/09/20 6:15 am, Jiandi An wrote:
>>>
>>>> On 08/09/20 12:39 am, Kun Zhao wrote:
>>>>>
>>>>> On 9/5/20 5:49 AM, Deepak Kodihalli wrote:
>>>>>> Hi Kun,
>>>>>>
>>>>>> On 05/09/20 5:32 am, Kun Zhao wrote:
>>>>>>> Hi Team,
>>>>>>>
>>>>>>> My platform is based on ast2500, and I’ve already been able to
>>>>>>> built out the ubi image. But when I tried to test it with qemu, it
>>>>>>> just stopped at u-boot because ‘can’t get kernel image,
>>>>>>>
>>>>>>> qemu-system-arm: Aspeed iBT has no chardev backend
>>>>>>>
>>>>>>> U-Boot 2016.07 (Sep 04 2020 - 19:47:48 +0000)
>>>>>>>
>>>>>>>            Watchdog enabled
>>>>>>>
>>>>>>> DRAM:  496 MiB
>>>>>>>
>>>>>>> Flash: 32 MiB
>>>>>>>
>>>>>>> *** Warning - bad CRC, using default environment
>>>>>>>
>>>>>>> In:    serial
>>>>>>>
>>>>>>> Out:   serial
>>>>>>>
>>>>>>> Err:   serial
>>>>>>>
>>>>>>> Net:   MAC0 : RGMII
>>>>>>>
>>>>>>> MAC1 : RGMII
>>>>>>>
>>>>>>> FTGMAC100#0
>>>>>>>
>>>>>>> Error: FTGMAC100#0 address not set.
>>>>>>>
>>>>>>> , FTGMAC100#1
>>>>>>>
>>>>>>> Error: FTGMAC100#1 address not set.
>>>>>>>
>>>>>>> Hit any key to stop autoboot:  0
>>>>>>>
>>>>>>> Wrong Image Format for bootm command
>>>>>>>
>>>>>>> ERROR: can't get kernel image!
>>>>>>>
>>>>>>> ast#
>>>>>>>
>>>>>>> And I found the bootargs is not right,
>>>>>>>
>>>>>>> ast# print
>>>>>>>
>>>>>>> baudrate=115200
>>>>>>>
>>>>>>> bootargs=console=ttyS4,115200n8 root=/dev/ram rw
>>>>>>>
>>>>>>> bootcmd=bootm 20080000
>>>>>>>
>>>>>>> bootdelay=2
>>>>>>>
>>>>>>> Checked in the build folder for
>>>>>>> tmp/work/myplatform-openbmc-linux-gnueabi/u-boot-aspeed/1_v2016.07
>>>>>>> +g
>>>>>>> itAUTOINC+1ded9fa3a2-r0/ and found the none of the following
>>>>>>> itAUTOINC+patches
>>>>>>> are there,
>>>>>>>
>>>>>>> 0002-config-ast-common-hack-bootopts.patch
>>>>>>>
>>>>>>> 0003-config-ast-common-Add-bootopts-to-support-ubi-and-mt.patch
>>>>>>>
>>>>>>> 0004-config-ast-common-Add-conditional-factory-reset-comm.patch
>>>>>>>
>>>>>>> 0005-config-ast-common-Fall-back-to-secondary-flash-on-fa.patch
>>>>>>>
>>>>>>> I think that’s why the bootargs is not correct.
>>>>>>>
>>>>>>> This is the details of how I enabled the ubi support in my
>>>>>>> platform recipes,
>>>>>>>
>>>>>>> 1. In meta-myplatform/conf/distro/openbmc-myplatform.conf, I
>>>>>>> added,
>>>>>>>
>>>>>>> require conf/distro/include/phosphor-base.inc
>>>>>>>
>>>>>>> require conf/distro/include/phosphor-ubi.inc
>>>>>>
>>>>>> You should just need the one line above, plus a device tree change
>>>>>> for your
>>>> system. The default openbmc-flash-layout.dtsi doesn't make a ubifs partition.
>>>> You can for eg look at witherspoon's dts, which uses ubifs.
>>>>> Hi Deepak, thank you for reply. I've tried to use the witherspoon's
>>>>> flash layout
>>>> per your tips here. But it still stops at u-boot with "can't get kernel image!"
>> error.
>>>> Do I need to enable any kernel config options?
>>>>
>>>>
>>>> Hi Kun, I don't think you need additional kernel config updates. I
>>>> suspect something wrong with the way the image is built. Are you able
>>>> to see expected values for the u-boot environment variables and MTD
>> partitions? For eg:
>>>>
>>>> ast# mtdparts
>>>> device nor0 <bmc>, # parts = 3
>>>>     #: name               size            offset          mask_flags
>>>>     0: u-boot              0x00060000     0x00000000      0
>>>>     1: u-boot-env          0x00020000     0x00060000      0
>>>>     2: obmc-ubi            0x01f80000     0x00080000      0
>>>> active partition: nor0,0 - (u-boot) 0x00060000 @ 0x00000000
>>>>
>>>
>>> Hi Deepak,
>>> One thing is no mtdparts command from u-boot.  Do we need to add
>> CONFIG_CMD_MTDPARTS?
>>> Here the comment says adding CONFIG_CMD_MTDPARTS won't work.
>>> https://lists.denx.de/pipermail/u-boot/2012-December/142837.html
>>
>> Hi Jiandi, the comment you pointed to is in the context if a very old u-boot release,
>> so I don't think it applies to the u-boot release that OpenBMC uses. MTD and UBI
>> support is optional in the u-boot AST config, and is enabled if
>> MTDPARTS_DEFAULT is set. This flag further sets CONFIG_MTD_PARTITIONS.
>> MTDPARTS_DEFAULT is enabled via a u-boot patch that we carry, and that is
>> picked up if the 'obmc-ubi-fs' distro feature is enabled (see meta-
>> phosphor/aspeed-layer/recipes-bsp/u-boot/u-boot-aspeed.inc). So it still seems
>> like this feature is not enabled in the image or there is some other issue with
>> building the image.
>>
>>> Actually using witherspoon's flash layout
>>> https://github.com/ibm-openbmc/openbmc/blob/OP940/meta-ibm/meta-
>> wither
>>> spoon/recipes-kernel/linux/linux-aspeed/0001-ARM-dts-Aspeed-Witherspoo
>>> n-128-Update-BMC-partitioni.patch
>>>
>>> So the one we have in the device tree is as follows..
>>
>> Witherspoon-128's (which has a different device tree than witherspoon) BMC has
>> a 128M flash (you can see the sizes of the partitions below in the device tree add
>> up to 128M). So this would work if your BMC has a 128M flash. The obmc-ubi
>> partition would be smaller for eg for a 32M flash.
> 
> Thanks Deepak.  So I tried with aspeed-bmc-opp-witherspoon.dts now
> https://elixir.bootlin.com/linux/latest/source/arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts#L231
> with obmc-ubi starting at 0x80000 with size 0x1F80000
> 
> &fmc {
> 	status = "okay";
> 	flash at 0 {
> 		status = "okay";
> 		m25p,fast-read;
> 		label = "bmc";
> //#include "openbmc-flash-layout.dtsi"
> 
> 		partitions {
> 			#address-cells = < 1 >;
> 			#size-cells = < 1 >;
> 			compatible = "fixed-partitions";
> 			u-boot at 0 {
> 				reg = < 0 0x60000 >;
> 				label = "u-boot";
> 			};
> 			u-boot-env at 60000 {
> 				reg = < 0x60000 0x20000 >;
> 				label = "u-boot-env";
> 			};
> 			obmc-ubi at 80000 {
> 				reg = <0x80000 0x1F80000>;
> 				label = "obmc-ubi";
> 			};
> 		};
> 	};
> };
> 
> Still seeing during kernel boot that /dev/mtdblock: can't open blockdev
> 
> [    1.356025] Checked W+X mappings: passed, no W+X pages found
> [    1.356346] Run /init as init process
> rofs = squashfs rwfs = jffs2
> [    2.033408] /dev/mtdblock: Can't open blockdev
> mount: mounting /dev/mtdblock on run/initramfs/ro failed: No such file or directory
> [    2.043247] MTD: Couldn't look up '/dev/mtdblock': -2
> mount: mounting /dev/mtdblock on run/initramfs/rw failed: No such file or directory
> 
> Mounting read-write /dev/mtdblock filesystem failed.  Please fix and run
> 	mount /dev/mtdblock run/initramfs/rw -t jffs2 -o rw
> to to continue, or do change nothing to run from RAM for this boot.
> Enter password to try to manually fix.
> After fixing run exit to continue this script, or reboot -f to retry, or
> touch /takeover and exit to become PID 1 allowing editing of this script.
> Give root password for system maintenance
> (or type Control-D for normal startup):
> 
> I searched and saw this feature discussion
> https://github.com/openbmc/openbmc/issues/3177
> which has a commit for uboot: Add support for ubi and mtd partitioning
> https://gerrit.openbmc-project.xyz/c/openbmc/openbmc/+/5911
> It went in meta-phosphor/common/recipes-bsp/u-boot/files/ as a patch.
> https://github.com/openbmc/openbmc/commit/dd7015393fdab93426aab61a08b48a698c9c100d

Yes, you do need the patch above, along with few other patches. See my 
previous mail in this thread about the 'obmc-ubi-fs' distro feature. If 
this is enabled, the u-boot patches should be applied. This distro 
feature is enabled by including conf/distro/include/phosphor-ubi.inc.

> There is also this
> https://gerrit.openbmc-project.xyz/c/openbmc/openbmc/+/10577

I'd have to check this one, but I'm certain you don't need this just to 
boot with ubifs.

> These are not in our code base.
> Do we need these patches?
> 
>>
>>> &fmc {
>>>        status = "okay";
>>>        flash at 0 {
>>>                status = "okay";
>>>                m25p,fast-read;
>>>                label = "bmc";
>>> //#include "openbmc-flash-layout.dtsi"
>>>
>>>                partitions {
>>>                        #address-cells = < 1 >;
>>>                        #size-cells = < 1 >;
>>>                        compatible = "fixed-partitions";
>>>                        u-boot at 0 {
>>>                                reg = < 0 0x60000 >;
>>>                                label = "u-boot";
>>>                        };
>>>                        u-boot-env at 60000 {
>>>                                reg = < 0x60000 0x20000 >;
>>>                                label = "u-boot-env";
>>>                        };
>>>                        obmc-ubi at 80000 {
>>>                                reg = <0x80000 0x7F80000>;
>>>                                label = "obmc-ubi";
>>>                        };
>>>                };
>>>        };
>>> };
>>>
>>>>
>>>>>> Does anyone know why the default is static partitions, and not ubifs?
>>>>>>
>>>>>> Regards,
>>>>>> Deepak
>>>>>>
>>>>>>> 2. In meta-myplatform/conf/machine/myplatform.conf, I added,
>>>>>>>
>>>>>>> IMAGE_FSTYPES += " mtd-ubi mtd-ubi-tar"
>>>>>>>
>>>>>>> OBMC_MACHINE_FEATURES += " obmc-ubi-fs"
>>>>>>>
>>>>>>> Do I miss anything?
>>>>>>>
>>>>>>> Thanks.
>>>>>>>
>>>>>>> Best regards,
>>>>>>>
>>>>>>> Kun Zhao
>>>>>>>
>>>>>>> /*
>>>>>>>
>>>>>>> zkxz at hotmail.com <mailto:zkxz at hotmail.com>
>>>>>>>
>>>>>>> */
>>>>>>>
>>>>>>
>>>>> Kun
>>>>>
>>>
> 



More information about the openbmc mailing list