[U-Boot] [PATCH v2 7/8] board: Add new slimbootloader board

Park, Aiden aiden.park at intel.com
Tue Jul 9 00:02:19 UTC 2019


Hi Bin,

> -----Original Message-----
> From: Park, Aiden
> Sent: Monday, July 8, 2019 9:48 AM
> To: Bin Meng <bmeng.cn at gmail.com>
> Cc: U-Boot Mailing List <u-boot at lists.denx.de>; Simon Glass
> <sjg at chromium.org>
> Subject: RE: [PATCH v2 7/8] board: Add new slimbootloader board
> 
> Hi Bin,
> 
> > -----Original Message-----
> > From: Bin Meng [mailto:bmeng.cn at gmail.com]
> > Sent: Tuesday, July 2, 2019 7:14 AM
> > To: Park, Aiden <aiden.park at intel.com>
> > Cc: U-Boot Mailing List <u-boot at lists.denx.de>; Simon Glass
> > <sjg at chromium.org>
> > Subject: Re: [PATCH v2 7/8] board: Add new slimbootloader board
> >
> > Hi Aiden,
> >
> > On Wed, Jun 26, 2019 at 7:21 AM Park, Aiden <aiden.park at intel.com>
> wrote:
> > >
> > > - Add new board/slimbootloader directory with minimum codes
> > > - Add slimbootloader configuration files
> > > - Add README in board/slimbootloader/slimbootloader/
> > >
> > > Signed-off-by: Aiden Park <aiden.park at intel.com>
> > > ---
> > >  arch/x86/Kconfig                              |  4 ++
> > >  board/slimbootloader/Kconfig                  | 25 ++++++++
> > >  board/slimbootloader/slimbootloader/Kconfig   | 51 +++++++++++++++
> > >  board/slimbootloader/slimbootloader/Makefile  |  5 ++
> > >  board/slimbootloader/slimbootloader/README    | 58
> > +++++++++++++++++
> > >  .../slimbootloader/slimbootloader.c           | 17 +++++
> > >  board/slimbootloader/slimbootloader/start.S   |  9 +++
> > >  configs/slimbootloader_defconfig              | 64 +++++++++++++++++++
> > >  include/configs/slimbootloader.h              | 54 ++++++++++++++++
> > >  9 files changed, 287 insertions(+)
> > >  create mode 100644 board/slimbootloader/Kconfig  create mode 100644
> > > board/slimbootloader/slimbootloader/Kconfig
> > >  create mode 100644 board/slimbootloader/slimbootloader/Makefile
> > >  create mode 100644 board/slimbootloader/slimbootloader/README
> > >  create mode 100644
> > > board/slimbootloader/slimbootloader/slimbootloader.c
> > >  create mode 100644 board/slimbootloader/slimbootloader/start.S
> > >  create mode 100644 configs/slimbootloader_defconfig  create mode
> > > 100644 include/configs/slimbootloader.h
> > >
> > > diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index
> > > 1612246dfc..3d57466a63 100644
> > > --- a/arch/x86/Kconfig
> > > +++ b/arch/x86/Kconfig
> > > @@ -77,6 +77,9 @@ config VENDOR_GOOGLE  config VENDOR_INTEL
> > >         bool "Intel"
> > >
> > > +config VENDOR_SLIMBOOTLOADER
> > > +       bool "slimbootloader"
> >
> > I think this should be "Intel".
> Okay. Let me use VENDOR_INTEL.
> >
> > > +
> > >  endchoice
> > >
> > >  # subarchitectures-specific options below @@ -104,6 +107,7 @@
> > > source "board/efi/Kconfig"
> > >  source "board/emulation/Kconfig"
> > >  source "board/google/Kconfig"
> > >  source "board/intel/Kconfig"
> > > +source "board/slimbootloader/Kconfig"
> >
> > So it becomes a "board" in board/intel directory.
> Okay. Let me use intel.
> >
> > >
> > >  # platform-specific options below
> > >  source "arch/x86/cpu/baytrail/Kconfig"
> > > diff --git a/board/slimbootloader/Kconfig
> > > b/board/slimbootloader/Kconfig new file mode 100644 index
> > > 0000000000..33c6fdf0aa
> > > --- /dev/null
> > > +++ b/board/slimbootloader/Kconfig
> > > @@ -0,0 +1,25 @@
> > > +# SPDX-License-Identifier: GPL-2.0+ # # Copyright (C) 2019 Intel
> > > +Corporation <www.intel.com>
> > > +
> > > +if VENDOR_SLIMBOOTLOADER
> > > +
> > > +choice
> > > +       prompt "Select a board"
> > > +       optional
> > > +
> > > +config TARGET_SLIMBOOTLOADER
> > > +       bool "slimbootloader"
> > > +       help
> > > +         This target is used for running U-Boot on top of Slim Bootloader
> > > +         boot firmware as a payload. Slim Bootloader does memory
> > initialization
> > > +         and silicon initialization, and it passes necessary information in
> > > +         HOB(Hand Off Block) to a payload. The payload is responsible for OS
> > > +         load from media and booting OS.
> > > +         Refer to board/slimbootloader/slimbootloader/README for
> > > + the
> > details.
> > > +
> > > +endchoice
> > > +
> > > +source "board/slimbootloader/slimbootloader/Kconfig"
> > > +
> > > +endif
> > > diff --git a/board/slimbootloader/slimbootloader/Kconfig
> > > b/board/slimbootloader/slimbootloader/Kconfig
> > > new file mode 100644
> > > index 0000000000..7262f2bf1b
> > > --- /dev/null
> > > +++ b/board/slimbootloader/slimbootloader/Kconfig
> > > @@ -0,0 +1,51 @@
> > > +# SPDX-License-Identifier: GPL-2.0+ # # Copyright (C) 2019 Intel
> > > +Corporation <www.intel.com>
> > > +
> > > +if TARGET_SLIMBOOTLOADER
> > > +
> > > +config SYS_BOARD
> > > +       default "slimbootloader"
> > > +
> > > +config SYS_VENDOR
> > > +       default "slimbootloader"
> > > +
> > > +config SYS_SOC
> > > +       default "slimbootloader"
> > > +
> > > +config SYS_TEXT_BASE
> > > +       default 0x00100000
> > > +
> > > +comment "slimbootloader-specific options"
> > > +
> > > +config SYS_CONFIG_NAME
> > > +       string "Board configuration file"
> > > +       default "slimbootloader"
> > > +       help
> > > +         This option selects the board configuration file in include/configs/
> > > +         directory to be used to build U-Boot for Slim Bootloader.
> > > +
> > > +config DEFAULT_DEVICE_TREE
> > > +       string "Board Device Tree Source (dts) file"
> > > +       default "slimbootloader"
> > > +       help
> > > +         This option selects the board Device Tree Source (dts) file in
> > > +         arch/x86/dts/ directory to be used to build U-Boot for
> > > +Slim
> > Bootloader.
> > > +
> > > +config SYS_CAR_ADDR
> > > +       hex "Board specific Cache-As-RAM (CAR) address"
> > > +       default 0x00000000
> > > +       help
> > > +         This option specifies the board specific Cache-As-RAM (CAR)
> address.
> > > +         But, CAR is not required for Slim Bootloader environment since it
> > > +         has already initialized memory and launched u-boot as a payload.
> > > +
> > > +config SYS_CAR_SIZE
> > > +       hex "Board specific Cache-As-RAM (CAR) size"
> > > +       default 0x0000
> > > +       help
> > > +         This option specifies the board specific Cache-As-RAM (CAR) size.
> > > +         But, CAR is not required for Slim Bootloader environment since it
> > > +         has already initialized memory and launched u-boot as a payload.
> > > +
> > > +endif
> > > diff --git a/board/slimbootloader/slimbootloader/Makefile
> > > b/board/slimbootloader/slimbootloader/Makefile
> > > new file mode 100644
> > > index 0000000000..fd8fa98a8d
> > > --- /dev/null
> > > +++ b/board/slimbootloader/slimbootloader/Makefile
> > > @@ -0,0 +1,5 @@
> > > +# SPDX-License-Identifier: GPL-2.0+ # # Copyright (C) 2019 Intel
> > > +Corporation <www.intel.com>
> > > +
> > > +obj-y  += start.o slimbootloader.o
> > > diff --git a/board/slimbootloader/slimbootloader/README
> > > b/board/slimbootloader/slimbootloader/README
> > > new file mode 100644
> > > index 0000000000..5492dc8883
> > > --- /dev/null
> > > +++ b/board/slimbootloader/slimbootloader/README
> > > @@ -0,0 +1,58 @@
> > > +# SPDX-License-Identifier: GPL-2.0+ # # Copyright (C) 2019 Intel
> > > +Corporation <www.intel.com>
> > > +
> > > +Introduction
> > > +============
> > > +This target is to enable U-Boot as a payload of Slim
> > > +Bootloader(a.k.a
> > > +SBL) boot
> > > +firmware(https://github.com/slimbootloader/slimbootloader)
> > > +which currently supports QEMU, Apollolake, Whiskeylake, Coffeelake-
> > Refresh platforms.
> > > +
> > > +The Slim Bootloader is designed with multi-stages(Stage1A/B,
> > > +Stage2,
> > > +Payload) architecture to cover from reset vector to OS booting and
> > > +it consumes Intel FSP
> > > +(https://github.com/IntelFsp/FSP) for silicon initialization.
> > > +* Stage1A: Reset vector, CAR init with FSP-T
> > > +* Stage1B: Memory init with FSP-M, CAR teardown, Continue execution
> > > +in memory
> > > +* Stage2 : Rest of Silicon init with FSP-S, Create HOB, Hand-off to
> > > +Payload
> > > +* Payload: Load OS from media, Booting OS
> > > +
> > > +
> > > +Here is the step-by-step to launch U-Boot on Slim Bootloader.
> > > +
> > > +Compile U-Boot
> > > +==============
> > > +
> > > +  > make slimbootloader_defconfig all  > strip u-boot (To make it
> > > + smaller size by removing debug symbols)
> > > +
> > > +
> > > +Compile Slim Bootloader with U-Boot
> > > +===================================
> > > +
> > > +For build environment:
> > > +
> > > +https://slimbootloader.github.io/getting-started/build-host-setup.h
> > > +tm
> > > +l
> > > +
> > > +Get source code:
> > > +  > git clone https://github.com/slimbootloader/slimbootloader.git
> > > +
> > > +Copy the built u-boot elf to Slim Bootloader source tree:
> > > +  > mkdir -p <slimbootloader_home>/PayloadPkg/PayloadBins/
> > > +  > cp <u-boot_home>/u-boot
> > > +<slimbootloader_home>/PayloadPkg/PayloadBins/
> > > +
> > > +Update default payload to U-Boot (PayloadId is 4 Bytes):
> > > +  > vi Platform/QemuBoardPkg/CfgData/CfgDataExt_Brd1.dlt
> > > +    -GEN_CFG_DATA.PayloadId                     | 'AUTO'
> > > +    +GEN_CFG_DATA.PayloadId                     | 'U-BT'
> > > +
> > > +Compile for QEMU target:
> > > +  The output is Outputs/qemu/SlimBootloader.bin
> > > +  > python BuildLoader.py build qemu -p
> > > +"OsLoader.efi:LLDR:Lz4;u-boot:U-
> > BT:Lzma"
> > > +
> > > +
> > > +Launch Slim Bootloader on QEMU
> > > +==============================
> > > +
> > > +  > qemu-system-x86_64 -machine q35 -m 256 -nographic -serial
> > mon:stdio
> > > +                       -pflash Outputs/qemu/SlimBootloader.bin
> > > +
> > > +Now, you should reach at U-Boot serial console.
> > > \ No newline at end of file
> > > diff --git a/board/slimbootloader/slimbootloader/slimbootloader.c
> > > b/board/slimbootloader/slimbootloader/slimbootloader.c
> > > new file mode 100644
> > > index 0000000000..d88aa622a0
> > > --- /dev/null
> > > +++ b/board/slimbootloader/slimbootloader/slimbootloader.c
> > > @@ -0,0 +1,17 @@
> > > +// SPDX-License-Identifier: GPL-2.0+
> > > +/*
> > > + * Copyright (C) 2019 Intel Corporation <www.intel.com>  */
> > > +
> > > +#include <common.h>
> > > +
> > > +int board_early_init_r(void)
> > > +{
> > > +       /*
> > > +        * Make sure PCI bus is enumerated so that peripherals on the PCI
> bus
> > > +        * can be discovered by their drivers
> > > +        */
> > > +       pci_init();
> > > +
> > > +       return 0;
> > > +}
> > > diff --git a/board/slimbootloader/slimbootloader/start.S
> > > b/board/slimbootloader/slimbootloader/start.S
> > > new file mode 100644
> > > index 0000000000..5c3f3df09e
> > > --- /dev/null
> > > +++ b/board/slimbootloader/slimbootloader/start.S
> > > @@ -0,0 +1,9 @@
> > > +/* SPDX-License-Identifier: GPL-2.0+ */
> > > +/*
> > > + * Copyright (C) 2019 Intel Corporation <www.intel.com>  */
> > > +
> > > +/* board early initialization */
> > > +.globl early_board_init
> > > +early_board_init:
> > > +       jmp     early_board_init_ret
> > > diff --git a/configs/slimbootloader_defconfig
> > > b/configs/slimbootloader_defconfig
> > > new file mode 100644
> > > index 0000000000..77ff3257b6
> > > --- /dev/null
> > > +++ b/configs/slimbootloader_defconfig
> > > @@ -0,0 +1,64 @@
> > > +CONFIG_X86=y
> > > +CONFIG_VENDOR_SLIMBOOTLOADER=y
> > > +CONFIG_TARGET_SLIMBOOTLOADER=y
> > > +CONFIG_X86_LOAD_FROM_32_BIT=y
> > > +CONFIG_REGMAP=y
> > > +CONFIG_SYSCON=y
> > > +CONFIG_SYS_CONSOLE_INFO_QUIET=y
> > > +CONFIG_BOARD_EARLY_INIT_R=y
> > > +CONFIG_LAST_STAGE_INIT=y
> > > +CONFIG_HUSH_PARSER=y
> > > +CONFIG_CMD_MMC=y
> > > +CONFIG_CMD_EXT2=y
> > > +CONFIG_CMD_FAT=y
> > > +CONFIG_CMD_USB=y
> > > +CONFIG_DOS_PARTITION=y
> > > +CONFIG_EFI_PARTITION=y
> > > +CONFIG_OF_CONTROL=y
> > > +CONFIG_OF_EMBED=y
> >
> > We should use OF_SEPARATE.
> Okay. Let me enable OF_SEPARATE.
I have a quick question. The reason I use OF_EMBED is to use u-boot ELF as Slim Bootloader payload because Slim Bootloader does not use fixed text address to load a payload. Is it okay to use OF_EMBED in this case? Or can you suggest better way? Thanks.
> >
> > > +CONFIG_BOOTSTAGE=y
> > > +CONFIG_BOOTSTAGE_REPORT=y
> > > +CONFIG_BOOTDELAY=10
> > > +CONFIG_CONSOLE_SCROLL_LINES=5
> > > +# CONFIG_PCI_PNP is not set
> > > +# CONFIG_I8259_PIC is not set
> > > +# CONFIG_APIC is not set
> > > +# CONFIG_CMD_EXT4_WRITE is not set
> > > +# CONFIG_CMD_FS_GENERIC is not set
> > > +# CONFIG_CMD_PART is not set
> > > +# CONFIG_CMD_TIME is not set
> > > +# CONFIG_CMD_BOOTSTAGE is not set
> > > +# CONFIG_CMD_DM is not set
> > > +# CONFIG_CMD_FLASH is not set
> > > +# CONFIG_CMD_LOADB is not set
> > > +# CONFIG_CMD_LOADS is not set
> > > +# CONFIG_CMD_SF_TEST is not set
> > > +# CONFIG_CMD_ECHO is not set
> > > +# CONFIG_CMD_ITEST is not set
> > > +# CONFIG_CMD_SETEXPR is not set
> > > +# CONFIG_CMD_NET is not set
> > > +# CONFIG_CMD_BOOTP is not set
> > > +# CONFIG_CMD_BLOCK_CACHE is not set # CONFIG_CMD_DATE is not
> set #
> > > +CONFIG_CMD_GETTIME is not set # CONFIG_CMD_MISC is not set #
> > > +CONFIG_CMD_IRQ is not set # CONFIG_CMD_ELF is not set #
> > > +CONFIG_CMD_IMI is not set # CONFIG_CMD_XIMG is not set #
> > > +CONFIG_CMD_EXPORTENV is not set # CONFIG_CMD_IMPORTENV is
> not set #
> > > +CONFIG_CMD_FDT is not set # CONFIG_CMD_GO is not set #
> > > +CONFIG_CMD_SAVEENV is not set # CONFIG_CMD_SOURCE is not set #
> > > +CONFIG_DM_KEYBOARD is not set # CONFIG_DM_VIDEO is not set #
> > > +CONFIG_DM_GPIO is not set # CONFIG_MMC_VERBOSE is not set #
> > > +CONFIG_GZIP is not set # CONFIG_HEXDUMP is not set #
> > > +CONFIG_EFI_LOADER is not set # CONFIG_GENERATE_SMBIOS_TABLE is
> not
> > > +set # CONFIG_IMAGE_FORMAT_LEGACY is not set # CONFIG_FIT is not
> set
> >
> > So many config options are turned off. Can we just turn off absolutely
> > necessary options that do not make sense for slim bootloader? eg:
> > CONFIG_PCI_PNP as we don't want U-Boot to redo the resource allocation.
> Only necessary option to be disabled is CONFIG_PCI_PNP. Other options
> were to reduce binary size. Let me recover all other configs.
> >
> > > diff --git a/include/configs/slimbootloader.h
> > > b/include/configs/slimbootloader.h
> > > new file mode 100644
> > > index 0000000000..bfd188de2c
> > > --- /dev/null
> > > +++ b/include/configs/slimbootloader.h
> > > @@ -0,0 +1,54 @@
> > > +/* SPDX-License-Identifier: GPL-2.0+ */
> > > +/*
> > > + * Copyright (C) 2019 Intel Corporation <www.intel.com>  */
> > > +
> > > +#ifndef __SLIMBOOTLOADER_CONFIG_H__ #define
> > > +__SLIMBOOTLOADER_CONFIG_H__
> > > +
> > > +#include <configs/x86-common.h>
> > > +
> > > +#undef CONFIG_NFSBOOTCOMMAND
> > > +#undef CONFIG_RAMBOOTCOMMAND
> > > +#undef CONFIG_EXTRA_ENV_SETTINGS
> > > +#undef CONFIG_BOOTCOMMAND
> > > +
> > > +/*-----------------------------------------------------------------
> > > +--
> > > +----
> > > + * For MEM32 uart
> > > + */
> >
> > nits: this needs to be better commented. And the multi-line comment
> > block format is wrong.
> Sure. I will do.
> >
> > > +/*#define CONFIG_SYS_NS16550_MEM32*/
> >
> > nits: remove this line.
> Okay. Thanks.
> >
> > > +#ifdef CONFIG_SYS_NS16550_MEM32
> > > +#undef CONFIG_SYS_NS16550_PORT_MAPPED #endif
> > > +
> > > +#define CONFIG_STD_DEVICES_SETTINGS            \
> > > +       "stdin=serial,i8042-kbd,usbkbd\0"       \
> > > +       "stdout=serial\0"                       \
> > > +       "stderr=serial\0"
> > > +
> > > +#define CONFIG_EXTRA_ENV_SETTINGS              \
> > > +       CONFIG_STD_DEVICES_SETTINGS             \
> > > +       "netdev=eth0\0"                         \
> > > +       "consoledev=ttyS0\0"                    \
> > > +       "ramdiskaddr=0x4000000\0"               \
> > > +       "ramdiskfile=initrd\0"                  \
> > > +       "bootdev=usb\0"                         \
> > > +       "bootdevnum=0\0"                        \
> > > +       "bootdevpart=0\0"                       \
> > > +       "bootfsload=fatload\0"                  \
> > > +       "bootusb=setenv bootdev usb; boot\0"    \
> > > +       "bootscsi=setenv bootdev scsi; boot\0"  \
> > > +       "bootmmc=setenv bootdev mmc; boot\0"    \
> > > +       "bootargs=console=ttyS0,115200 console=tty0\0"
> > > +
> > > +#define CONFIG_BOOTCOMMAND                                             \
> > > +       "if test ${bootdev} = \"usb\"; then ${bootdev} start; fi; "     \
> > > +       "if test ${bootdev} = \"scsi\"; then ${bootdev} scan; fi; "     \
> > > +       "${bootdev} info; "                                             \
> > > +       "${bootfsload} ${bootdev} ${bootdevnum}:${bootdevpart} "        \
> > > +       "${loadaddr} ${bootfile}; "                                     \
> > > +       "${bootfsload} ${bootdev} ${bootdevnum}:${bootdevpart} "        \
> > > +       "${ramdiskaddr} ${ramdiskfile}; "                               \
> > > +       "zboot ${loadaddr} 0 ${ramdiskaddr} ${filesize}"
> > > +
> > > +#endif /* __SLIMBOOTLOADER_CONFIG_H__ */
> > > --
> >
> > Regards,
> > Bin
> 
> Best Regards,
> Aiden

Best Regards,
Aiden


More information about the U-Boot mailing list