u-boot: load a kernel that's in a ubi volume

anoo anoo at linux.vnet.ibm.com
Tue Aug 8 01:34:36 AEST 2017


On 2017-08-07 02:36, Joel Stanley wrote:
> On Mon, Aug 7, 2017 at 1:39 PM, anoo <anoo at linux.vnet.ibm.com> wrote:
>> Hi Joel,
>> 
>> Per our discussion, here are the details of what we’re trying to do 
>> and the
>> things I’ve tried.
> 
> Thanks. I spent the afternoon attempting to recreate your results.
> 
>> 
>> Goal: Have u-boot load a kernel that's in a ubi volume.
>> 
>> 1. Added ubi support to uboot by adding the following macros to
>> include/configs/ast-g5-ncsi.h temporarily for testing purposes (a new 
>> config
>> header would probably need to be created for a final implementation):
>> 
>> | +#define CONFIG_CMD_UBI
>> | +#define CONFIG_CMD_UBIFS
>> | +#define CONFIG_RBTREE
>> | +#define CONFIG_MTD_DEVICE
>> | +#define CONFIG_MTD_PARTITIONS
>> | +#define CONFIG_CMD_MTDPARTS
>> | +#define CONFIG_LZO
> 
> I replicated this. I noted that this increases the size of the u-boot
> image a lot:
> 
> Old size: 232632
> New size: 358320
> 
> This is an extra 122kB, or a 54% increase in the u-boot size.
> 
> It does still fit in the partition we have, which is 384 KB.

Definitely something to keep in mind.

> 
>> 
>> 2. Built a romulus image with the above u-boot change plus commit
>> https://gerrit.openbmc-project.xyz/#/c/5812/ which is the top-most 
>> commit
>> for a set of changes to remove the initramfs and create a flash image 
>> that
>> builds the kernel and rootsfs into ubi volumes.
> 
> Why Romulus? Isn't this work being done for Witherspoon?

Yeah, this is being done for witherspoon. I've tested with witherspoon 
as well but also Romulus in case there were device tree changes that 
needed to be done that's a smaller system.

>> 3. Used the generated obmc-phosphor-image-romulus.ubi.mtd to boot 
>> qemu.
> 
> What was the Qemu command line you used?

After cloning the openbmc/qemu repo and building (using as reference 
https://github.com/openbmc/docs/blob/master/cheatsheet.md#using-qemu):

./build/arm-softmmu/qemu-system-arm -m 256 -M romulus-bmc -nographic 
-drive 
file=/<path_to>/obmc-phosphor-image-romulus.ubi.mtd,format=raw,if=mtd 
-net nic -net 
user,hostfwd=:127.0.0.1:2222-:22,hostfwd=:127.0.0.1:2443-:443,hostfwd=:127.0.0.1:2300-:3000,hostname=qemu

For witherspoon, I use the same command, just pointing to a withespoon 
image.

> 
> Can you share a mkfs.ubifs command line that I can use to create a ubi 
> image?

You can create a config test file (named ubi.cfg in this example) in a 
directory where you have the kernel fit image fitImage-<system>.bin, ex:

$ cat ubi.cfg
[kernel0]
mode=ubi
image=fitImage-<system>.bin
vol_type=static
vol_name=kernel0
vol_id=0

Then use ubinize command:
$ ubinize -p 64 -m 1 -o <outputfilename> ubi.cfg

The ubinize command is being added to the openbmc build with this 
commit: 
https://gerrit.openbmc-project.xyz/#/c/5801/3/meta-phosphor/classes/image_types_phosphor.bbclass

The rwfs is built with:
"UBIFS_RWFS_CMD = "mkfs.ubifs -r ubifs -c ${FLASH_UBI_RWFS_LEBS} -m 
${FLASH_PAGE_SIZE} -e ${FLASH_LEB_SIZE}KiB rwfs.ubifs"

Then the ubi image is built with:
"ubinize -p ${FLASH_PEB_SIZE}KiB -m ${FLASH_PAGE_SIZE} -o ubi-img $cfg"

> 
> When I tried to boot the image I downloaded from the gerrit job, none
> of the uboot commands you listed worked:

An image needs to built with the u-boot changes that enable ubi, since 
that is not in gerrit. You'd need to build an openbmc image with the 
u-boot recipe pointing to a local u-boot repo that has the ubi macros 
enabled.

I'll pass you in a separate msg the image I have built.

> 
> U-Boot 2016.07 (Jul 27 2017 - 21:13:25 +0000)
> 
>        Watchdog enabled
> DRAM:  496 MiB
> Flash: 32 MiB
> *** Warning - bad CRC, using default environment
> 
> In:    serial
> Out:   serial
> Err:   serial
> Net:   aspeednic#0
> Error: aspeednic#0 address not set.
> 
> Hit any key to stop autoboot:  0
> libfdt fdt_check_header(): FDT_ERR_BADMAGIC
> Wrong Image Format for bootm command
> ERROR: can't get kernel image!
> ast# mtdparts
> Unknown command 'mtdparts' - try 'help'
> ast# ubi part kernel0
> Unknown command 'ubi' - try 'help'
> 
> 
>> 
>> 4. To be able to use ubi in u-boot, the mtdparts and mtdids variables 
>> need
>> to be set (reference:
>> https://fossies.org/linux/qemu/roms/u-boot/doc/README.ubi).
>> 
>> Here is where I’ve been unable to get u-boot to recognize the 
>> existing mtd.
>> I’ve tried multiple combinations for mtdids, such as nor0=bmc,
>> nor0=<addr>.flash, etc etc. But when running “mtdparts” command 
>> from u-boot,
>> or a ubi command, always get "Device nor0 not found!”. Ex:
>> 
>> ast# mtdparts
>> Device nor0 not found!
>> 
>> ast# ubi part kernel0
>> Device nor0 not found!
>> Error initializing mtdparts!
>> 
>> I’ve also taken a stab at adding the romulus device tree to u-boot 
>> to see if
>> that may be the reason, by copying from the kernel and adding to 
>> u-boot the
>> files arch/arm/dts/aspeed-g5.dtsi, aspeed-bmc-opp-flash-layout.dtsi,
>> aspeed-bmc-opp-romulus.dts, and adding the dts to the Makefile. Also 
>> added a
>> CONFIG_DEFAULT_DEVICE_TREE macro. This might not be the correct or 
>> complete
>> way to add the device tree to the openbmc version of u-boot.
> 
> Can you explain what you were trying to do there?

I was trying to add the system device tree to u-boot. The device trees 
for the openbmc systems are defined in the kernel, but they may be 
required to be defined in u-boot for u-boot to find the mtd partitions.

> 
> Cheers,
> 
> Joel



More information about the openbmc mailing list