microblaze: External initrd support
Subsystems (2)
cover microblaze: External initrd support
Hi,
Microblaze is not changing a lot but there was a real pain for not supporting external initrd. That's why several patches in the series are fixing this issue. The rest of patches are just cleanup which I found when I was trying to fix it.
Thanks,
Michal
Michal Simek (10):
microblaze: Remove unused variable ram_base
microblaze: Move CONFIG_LMB from board file to config.h
microblaze: Fix lmb memory initialization
microblaze: Define arch_lmb_reserve
microblaze: Switch to generic bootm implementation
microblaze: Enable cache by default
microblaze: Setup reasonable maximum bootm len
microblaze: Setup initrd_high and fdt_high at run time
microblaze: Remove additional headers
microblaze: Enable random mac generation
arch/microblaze/Kconfig | 8 ++ arch/microblaze/include/asm/config.h | 4 + arch/microblaze/lib/bootm.c | 136 +++++++++++------- .../microblaze-generic/microblaze-generic.c | 28 ++-- common/image.c | 5 +- configs/microblaze-generic_defconfig | 2 + include/configs/microblaze-generic.h | 8 +- 7 files changed, 129 insertions(+), 62 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/10 microblaze: Remove unused variable ram_base
This variable is completely unused that's why remove it.
---
board/xilinx/microblaze-generic/microblaze-generic.c | 2 -- 1 file changed, 2 deletions(-)
board/xilinx/microblaze-generic/microblaze-generic.c +0 -2
@@ -24,8 +24,6 @@DECLARE_GLOBAL_DATA_PTR ; -ulong ram_base; -int dram_init_banksize (void ) {return fdtdec_setup_memory_banksize ();
Signature · 1 line
2.17.1
PATCH 2/10 microblaze: Move CONFIG_LMB from board file to config.h
In reply to Michal SimekIt is common for the whole architecture that's why move it there.
---
arch/microblaze/include/asm/config.h | 2 ++ include/configs/microblaze-generic.h | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-)
arch/microblaze/include/asm/config.h +2 -0
@@ -6,6 +6,8 @@#ifndef _ASM_CONFIG_H_#define _ASM_CONFIG_H_ +#define CONFIG_LMB +#ifndef CONFIG_SPL_BUILD #define CONFIG_NEEDS_MANUAL_RELOC #endif
include/configs/microblaze-generic.h +0 -3
@@ -152,9 +152,6 @@ "setenv stdin serial\0"#endif -/* Enable flat device tree support */ -#define CONFIG_LMB 1 -#if defined(CONFIG_XILINX_AXIEMAC )# define CONFIG_SYS_FAULT_ECHO_LINK_DOWN 1#endif
Signature · 1 line
2.17.1
PATCH 3/10 microblaze: Fix lmb memory initialization
In reply to Michal SimekMicroblaze as Arm is using multiple memory banks which are read from DT that's why there is a need to initialized LMB based on bd->bi_dram[]. Without this fix memory base/size is all the time 0 and image relocation is not possible.
---
common/image.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
common/image.c +3 -2
@@ -582,7 +582,7 @@ ulong env_get_bootm_low(void)#if defined(CONFIG_SYS_SDRAM_BASE )return CONFIG_SYS_SDRAM_BASE ; -#elif defined(CONFIG_ARM ) +#elif defined(CONFIG_ARM ) || defined(CONFIG_MICROBLAZE )return gd->bd->bi_dram[0 ].start;#else return 0 ;
@@ -599,7 +599,8 @@ phys_size_t env_get_bootm_size(void)return tmp; } -#if defined(CONFIG_ARM ) && defined(CONFIG_NR_DRAM_BANKS ) +#if (defined(CONFIG_ARM ) || defined(CONFIG_MICROBLAZE )) && \ + defined(CONFIG_NR_DRAM_BANKS ) start = gd->bd->bi_dram[0 ].start; size = gd->bd->bi_dram[0 ].size;#else
Signature · 1 line
2.17.1
PATCH 4/10 microblaze: Define arch_lmb_reserve
In reply to Michal Simekarch_lmb_reserve() protects U-Boot relocated code with stack not to be used for image relocation.
---
arch/microblaze/lib/bootm.c | 41 +++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
arch/microblaze/lib/bootm.c +41 -0
@@ -15,6 +15,47 @@#include <u-boot/zlib.h> #include <asm/byteorder.h> +DECLARE_GLOBAL_DATA_PTR ; + +static ulong get_sp (void ) +{ +ulong ret; + + asm("addik %0, r1, 0" :"=r" (ret) : ); +return ret; +} + +void arch_lmb_reserve (struct lmb *lmb) +{ +ulong sp, bank_end; +int bank; + +/* +* Booting a (Linux) kernel image +* +* Allocate space for command line and board info - the +* address should be as high as possible within the reach of +* the kernel (see CONFIG_SYS_BOOTMAPSZ settings), but in unused +* memory, which means far enough below the current stack +* pointer. +*/ + sp =get_sp (); +debug ("## Current stack ends at 0x%08lx " , sp); + +/* adjust sp by 4K to be safe */ + sp -=4096 ; +for (bank =0 ; bank <CONFIG_NR_DRAM_BANKS ; bank++) { +if (sp < gd->bd->bi_dram[bank].start) +continue ; + bank_end = gd->bd->bi_dram[bank].start + + gd->bd->bi_dram[bank].size; +if (sp >= bank_end) +continue ; +lmb_reserve (lmb, sp, bank_end - sp); +break ; + } +} +int do_bootm_linux (int flag,int argc,char *const argv[],bootm_headers_t *images) {
Signature · 1 line
2.17.1
PATCH 5/10 microblaze: Switch to generic bootm implementation
In reply to Michal SimekThere is no reason to use private code for standard bootm command. Current implementation is also broken and don't support image relocation properly. Switching to generic bootm implementation is fixing these issues.
cmdline and bdt bootm subcommands are returning -1 because they are not implemented.
Similar change was done long time ago by for example commit 2bb5b638791d ("MIPS: bootm: rework and fix broken bootm code")
---
arch/microblaze/include/asm/config.h | 2 + arch/microblaze/lib/bootm.c | 105 +++++++++++++-------------- 2 files changed, 54 insertions(+), 53 deletions(-)
arch/microblaze/include/asm/config.h +2 -0
@@ -12,4 +12,6 @@#define CONFIG_NEEDS_MANUAL_RELOC #endif +#define CONFIG_SYS_BOOT_RAMDISK_HIGH +#endif
arch/microblaze/lib/bootm.c +52 -53
123 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 6/10 microblaze: Enable cache by default
In reply to Michal SimekThe whole cache code needs to be redesign to read information about cache from DT instead of macro selection. Enable caches by default because systems have caches on by default for Linux.
Also enable CMD_CACHE to be able to disable cache if there is any issue.
---
configs/microblaze-generic_defconfig | 1 + include/configs/microblaze-generic.h | 3 +++ 2 files changed, 4 insertions(+)
configs/microblaze-generic_defconfig +1 -0
@@ -34,6 +34,7 @@ CONFIG_CMD_DHCP=y CONFIG_CMD_TFTPPUT=y CONFIG_CMD_MII=y CONFIG_CMD_PING=y +CONFIG_CMD_CACHE=y CONFIG_CMD_JFFS2=y CONFIG_SPL_OF_CONTROL=y CONFIG_OF_EMBED=y
include/configs/microblaze-generic.h +3 -0
@@ -100,6 +100,9 @@#endif /* !SPIFLASH */ #endif /* !FLASH */ +#define XILINX_USE_ICACHE 1 +#define XILINX_USE_DCACHE 1 +#if defined(XILINX_USE_ICACHE )# define CONFIG_ICACHE #else
Signature · 1 line
2.17.1
PATCH 7/10 microblaze: Setup reasonable maximum bootm len
In reply to Michal SimekWe are far from 8MB default size. Setup 64MB for now.
---
include/configs/microblaze-generic.h | 2 ++ 1 file changed, 2 insertions(+)
include/configs/microblaze-generic.h +2 -0
@@ -13,6 +13,8 @@/* MicroBlaze CPU */ #define MICROBLAZE_V5 1 +#define CONFIG_SYS_BOOTM_LEN (64 * 1024 * 1024) +/* linear and spi flash memory */ #ifdef XILINX_FLASH_START #define FLASH
Signature · 1 line
2.17.1
PATCH 8/10 microblaze: Setup initrd_high and fdt_high at run time
In reply to Michal SimekSetup initrd_high and fdt_high to be placed in lowmem space for kernel to be able to reach it. Values are setup at run time to ensure that the same setting can be used on different memory setup. Do this setting only when variables are not
Similar run time detection was done for Zynqmp and Versal.
---
arch/microblaze/Kconfig | 8 ++++++++ .../microblaze-generic/microblaze-generic.c | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+)
arch/microblaze/Kconfig +8 -0
@@ -20,6 +20,14 @@ config TARGET_MICROBLAZE_GENERIC endchoice +config STACK_SIZE + hex "Define max stack size that can be used by u-boot" + default 0x200000 + help + Defines Max stack size that can be used by u-boot so that the + initrd_high will be calculated as base stack pointer minus this + stack size. + source "board/xilinx/microblaze-generic/Kconfig" config SPL_LDSCRIPT
board/xilinx/microblaze-generic/microblaze-generic.c +19 -0
@@ -21,6 +21,7 @@#include <asm/gpio.h> #include <dm/uclass.h> #include <wdt.h> +#include <linux/sizes.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -39,6 +40,8 @@ int dram_init(void)int board_late_init (void ) { +ulong max_size, lowmem_size; +#if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_SYSRESET_MICROBLAZE )int ret;
@@ -47,5 +50,21 @@ int board_late_init(void)if (ret)printf ("Warning: No reset driver: ret=%d\n" , ret);#endif + +if (!(gd->flags &GD_FLG_ENV_DEFAULT )) { +debug ("Saved variables - Skipping\n" ); +return 0 ; + } + + max_size = gd->start_addr_sp -CONFIG_STACK_SIZE ; + max_size =round_down (max_size,SZ_16M ); + +/* Linux default LOWMEM_SIZE is 0x30000000 = 768MB */ + lowmem_size = gd->ram_base +768 *1024 *1024 ; + +env_set_addr ("initrd_high" , (void *)min_t (ulong, max_size, + lowmem_size)); +env_set_addr ("fdt_high" , (void *)min_t (ulong, max_size, lowmem_size)); +return 0 ; }
Signature · 1 line
2.17.1
PATCH 9/10 microblaze: Remove additional headers
In reply to Michal SimekThere were several changes in past in this file without removing headers (watchdog cleanup, soft reset, etc). That's why remove additional useless headers.
---
board/xilinx/microblaze-generic/microblaze-generic.c | 7 ------- 1 file changed, 7 deletions(-)
board/xilinx/microblaze-generic/microblaze-generic.c +0 -7
@@ -12,15 +12,8 @@#include <common.h> #include <config.h> -#include <dm.h> #include <dm/lists.h> #include <fdtdec.h> -#include <asm/processor.h> -#include <asm/microblaze_intc.h> -#include <asm/asm.h> -#include <asm/gpio.h> -#include <dm/uclass.h> -#include <wdt.h> #include <linux/sizes.h> DECLARE_GLOBAL_DATA_PTR ;
Signature · 1 line
2.17.1
PATCH 10/10 microblaze: Enable random mac generation
In reply to Michal SimekIn case that mac address is not found it is generated randomly.
---
configs/microblaze-generic_defconfig | 1 + 1 file changed, 1 insertion(+)
configs/microblaze-generic_defconfig +1 -0
@@ -39,6 +39,7 @@ CONFIG_CMD_JFFS2=y CONFIG_SPL_OF_CONTROL=y CONFIG_OF_EMBED=y CONFIG_DEFAULT_DEVICE_TREE="microblaze-generic" +CONFIG_NET_RANDOM_ETHADDR=y CONFIG_NETCONSOLE=y CONFIG_SPL_DM=y CONFIG_XILINX_GPIO=y
Signature · 1 line
2.17.1
Michal Simek
maintainercover microblaze: External initrd support
In reply to Michal Simekst 25. 9. 2019 v 13:42 odesÃlatel Michal Simek <[email protected]> napsal:
Quoted 33 lines
Hi,
Microblaze is not changing a lot but there was a real pain for not supporting external initrd. That's why several patches in the series are fixing this issue. The rest of patches are just cleanup which I found when I was trying to fix it.
Thanks,
MichalMichal Simek (10):
microblaze: Remove unused variableram_base
microblaze: MoveCONFIG_LMBfrom board file toconfig.h
microblaze: Fix lmb memory initialization
microblaze: Definearch_lmb_reserve
microblaze: Switch to generic bootm implementation
microblaze: Enable cache by default
microblaze: Setup reasonable maximum bootm len
microblaze: Setupinitrd_highandfdt_highat run time
microblaze: Remove additional headers
microblaze: Enable random mac generationarch/microblaze/Kconfig | 8 ++ arch/microblaze/include/asm/config.h | 4 + arch/microblaze/lib/bootm.c | 136 +++++++++++------- .../microblaze-generic/microblaze-generic.c | 28 ++-- common/image.c | 5 +- configs/microblaze-generic_defconfig | 2 + include/configs/microblaze-generic.h | 8 +- 7 files changed, 129 insertions(+), 62 deletions(-)
Quoted 3 lines
--
2.17.1
Applied all.
M
Signature · 5 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91 w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel - Xilinx Microblaze Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs