Enable UBI support for a platform

Deepak Kodihalli dkodihal at linux.vnet.ibm.com
Wed Sep 9 18:54:01 AEST 2020


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 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-witherspoon/recipes-kernel/linux/linux-aspeed/0001-ARM-dts-Aspeed-Witherspoon-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.

> &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