16a11cf48SDaniel SchwierzeckGeneric SPL framework 26a11cf48SDaniel Schwierzeck===================== 36a11cf48SDaniel Schwierzeck 46a11cf48SDaniel SchwierzeckOverview 56a11cf48SDaniel Schwierzeck-------- 66a11cf48SDaniel Schwierzeck 76a11cf48SDaniel SchwierzeckTo unify all existing implementations for a secondary program loader (SPL) 86a11cf48SDaniel Schwierzeckand to allow simply adding of new implementations this generic SPL framework 96a11cf48SDaniel Schwierzeckhas been created. With this framework almost all source files for a board 106a11cf48SDaniel Schwierzeckcan be reused. No code duplication or symlinking is necessary anymore. 116a11cf48SDaniel Schwierzeck 126a11cf48SDaniel Schwierzeck 136a11cf48SDaniel SchwierzeckHow it works 146a11cf48SDaniel Schwierzeck------------ 156a11cf48SDaniel Schwierzeck 16c01f87c8SMasahiro YamadaThe object files for SPL are built separately and placed in the "spl" directory. 176a11cf48SDaniel SchwierzeckThe final binaries which are generated are u-boot-spl, u-boot-spl.bin and 186a11cf48SDaniel Schwierzecku-boot-spl.map. 196a11cf48SDaniel Schwierzeck 20c01f87c8SMasahiro YamadaA config option named CONFIG_SPL_BUILD is enabled by Kconfig for SPL. 216a11cf48SDaniel SchwierzeckSource files can therefore be compiled for SPL with different settings. 226a11cf48SDaniel Schwierzeck 236a11cf48SDaniel SchwierzeckFor example: 246a11cf48SDaniel Schwierzeck 256a11cf48SDaniel Schwierzeckifeq ($(CONFIG_SPL_BUILD),y) 26c01f87c8SMasahiro Yamadaobj-y += board_spl.o 276a11cf48SDaniel Schwierzeckelse 28c01f87c8SMasahiro Yamadaobj-y += board.o 296a11cf48SDaniel Schwierzeckendif 306a11cf48SDaniel Schwierzeck 31c01f87c8SMasahiro Yamadaobj-$(CONFIG_SPL_BUILD) += foo.o 326a11cf48SDaniel Schwierzeck 336a11cf48SDaniel Schwierzeck#ifdef CONFIG_SPL_BUILD 346a11cf48SDaniel Schwierzeck foo(); 356a11cf48SDaniel Schwierzeck#endif 366a11cf48SDaniel Schwierzeck 376a11cf48SDaniel Schwierzeck 38c01f87c8SMasahiro YamadaThe building of SPL images can be enabled by CONFIG_SPL option in Kconfig. 396a11cf48SDaniel Schwierzeck 40fd3d28e7SPeter MeerwaldBecause SPL images normally have a different text base, one has to be 41fd3d28e7SPeter Meerwaldconfigured by defining CONFIG_SPL_TEXT_BASE. The linker script has to be 426a11cf48SDaniel Schwierzeckdefined with CONFIG_SPL_LDSCRIPT. 436a11cf48SDaniel Schwierzeck 446a11cf48SDaniel SchwierzeckTo support generic U-Boot libraries and drivers in the SPL binary one can 456a11cf48SDaniel Schwierzeckoptionally define CONFIG_SPL_XXX_SUPPORT. Currently following options 466a11cf48SDaniel Schwierzeckare supported: 476a11cf48SDaniel Schwierzeck 486a11cf48SDaniel SchwierzeckCONFIG_SPL_LIBCOMMON_SUPPORT (common/libcommon.o) 496a11cf48SDaniel SchwierzeckCONFIG_SPL_LIBDISK_SUPPORT (disk/libdisk.o) 506a11cf48SDaniel SchwierzeckCONFIG_SPL_I2C_SUPPORT (drivers/i2c/libi2c.o) 516a11cf48SDaniel SchwierzeckCONFIG_SPL_GPIO_SUPPORT (drivers/gpio/libgpio.o) 526a11cf48SDaniel SchwierzeckCONFIG_SPL_MMC_SUPPORT (drivers/mmc/libmmc.o) 536a11cf48SDaniel SchwierzeckCONFIG_SPL_SERIAL_SUPPORT (drivers/serial/libserial.o) 546a11cf48SDaniel SchwierzeckCONFIG_SPL_SPI_FLASH_SUPPORT (drivers/mtd/spi/libspi_flash.o) 556a11cf48SDaniel SchwierzeckCONFIG_SPL_SPI_SUPPORT (drivers/spi/libspi.o) 560c3a9ed4STien Fong CheeCONFIG_SPL_FS_FAT (fs/fat/libfat.o) 57*f4b40924STien Fong CheeCONFIG_SPL_FS_EXT4 586a11cf48SDaniel SchwierzeckCONFIG_SPL_LIBGENERIC_SUPPORT (lib/libgeneric.o) 59682b3a81SSimon SchwarzCONFIG_SPL_POWER_SUPPORT (drivers/power/libpower.o) 60a430fa06SMiquel RaynalCONFIG_SPL_NAND_SUPPORT (drivers/mtd/nand/raw/libnand.o) 616609916eSPo LiuCONFIG_SPL_DRIVERS_MISC_SUPPORT (drivers/misc) 623a0d60c5SSimon SchwarzCONFIG_SPL_DMA_SUPPORT (drivers/dma/libdma.o) 6318e8ff18SHeiko SchocherCONFIG_SPL_POST_MEM_SUPPORT (post/drivers/memory.o) 64a430fa06SMiquel RaynalCONFIG_SPL_NAND_LOAD (drivers/mtd/nand/raw/nand_spl_load.o) 6532b11273SChristian RieschCONFIG_SPL_SPI_LOAD (drivers/mtd/spi/spi_spl_load.o) 66c57b953dSPavel MachekCONFIG_SPL_RAM_DEVICE (common/spl/spl.c) 67a09f9649SHeiko SchocherCONFIG_SPL_WATCHDOG_SUPPORT (drivers/watchdog/libwatchdog.o) 68d22650afSAllen Martin 69f8e754d5STom Rini 70f8e754d5STom RiniDebugging 71f8e754d5STom Rini--------- 72f8e754d5STom Rini 73f8e754d5STom RiniWhen building SPL with DEBUG set you may also need to set CONFIG_PANIC_HANG 74f8e754d5STom Rinias in most cases do_reset is not defined within SPL. 75c3567d80STom Rini 76c3567d80STom Rini 77c3567d80STom RiniEstimating stack usage 78c3567d80STom Rini---------------------- 79c3567d80STom Rini 80c3567d80STom RiniWith gcc 4.6 (and later) and the use of GNU cflow it is possible to estimate 81c3567d80STom Rinistack usage at various points in run sequence of SPL. The -fstack-usage option 82c3567d80STom Rinito gcc will produce '.su' files (such as arch/arm/cpu/armv7/syslib.su) that 83c3567d80STom Riniwill give stack usage information and cflow can construct program flow. 84c3567d80STom Rini 85c3567d80STom RiniMust have gcc 4.6 or later, which supports -fstack-usage 86c3567d80STom Rini 87c3567d80STom Rini1) Build normally 88c3567d80STom Rini2) Perform the following shell command to generate a list of C files used in 89c3567d80STom RiniSPL: 90c3567d80STom Rini$ find spl -name '*.su' | sed -e 's:^spl/::' -e 's:[.]su$:.c:' > used-spl.list 91c3567d80STom Rini3) Execute cflow: 92c3567d80STom Rini$ cflow --main=board_init_r `cat used-spl.list` 2>&1 | $PAGER 93c3567d80STom Rini 94c3567d80STom Rinicflow will spit out a number of warnings as it does not parse 95c3567d80STom Rinithe config files and picks functions based on #ifdef. Parsing the '.i' 96c3567d80STom Rinifiles instead introduces another set of headaches. These warnings are 97c3567d80STom Rininot usually important to understanding the flow, however. 98