nios2: add device tree control of U-Boot
cover nios2: add device tree control of U-Boot
These patches add device tree control of U-Boot to nios2 boards.
In case of separated device tree blob, the blob is relocated from the end of u-boot-dtb.bin image.
Thomas Chou (5):
nios2: permit device tree control of U-Boot
nios2: enable device tree control of U-Boot
nios2: revert _end symbol in link script
nios2: initialize stack earlier in startup
nios2: relocate dtb for separated device tree
arch/Kconfig | 1 + arch/nios2/cpu/fdt.c | 20 ++++- arch/nios2/cpu/start.S | 55 +++++++------ arch/nios2/cpu/u-boot.lds | 16 +++- arch/nios2/dts/.gitignore | 1 + arch/nios2/dts/3c120_devboard.dts | 164 +++++++++++++++++++++++++++++++++++++ arch/nios2/dts/Makefile | 11 +++ arch/nios2/dts/include/dt-bindings | 1 + configs/nios2-generic_defconfig | 2 + 9 files changed, 244 insertions(+), 27 deletions(-) create mode 100644 arch/nios2/dts/.gitignore create mode 100644 arch/nios2/dts/3c120_devboard.dts create mode 100644 arch/nios2/dts/Makefile create mode 120000 arch/nios2/dts/include/dt-bindings
Signature · 1 line
2.1.4
PATCH 1/5 nios2: permit device tree control of U-Boot
Enable this in the Kconfig so that nios2 boards can use device tree to configure U-Boot.
--- arch/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/Kconfig +1 -0
@@ -63,6 +63,7 @@ config NIOS2 bool "Nios II architecture" select HAVE_GENERIC_BOARD select SYS_GENERIC_BOARD + select SUPPORT_OF_CONTROL config OPENRISC bool "OpenRISC architecture"
Signature · 1 line
2.1.4
PATCH 1/5 nios2: permit device tree control of U-Boot
Quoted 7 lines · Thomas Chou
Enable this in the
Kconfigso that nios2 boards can use device tree to configure U-Boot.Signed-off-by Thomas Chou <[email protected]>--- arch/Kconfig | 1 + 1 file changed, 1 insertion(+)
PATCH 2/5 nios2: enable device tree control of U-Boot
In reply to Thomas ChouThis patch adds device tree control of U-Boot to nios2 boards. The example dts is taken from Linux kernel.
--- arch/nios2/dts/.gitignore | 1 + arch/nios2/dts/3c120_devboard.dts | 164 +++++++++++++++++++++++++++++++++++++ arch/nios2/dts/Makefile | 11 +++ arch/nios2/dts/include/dt-bindings | 1 + configs/nios2-generic_defconfig | 2 + 5 files changed, 179 insertions(+) create mode 100644 arch/nios2/dts/.gitignore create mode 100644 arch/nios2/dts/3c120_devboard.dts create mode 100644 arch/nios2/dts/Makefile create mode 120000 arch/nios2/dts/include/dt-bindings
arch/nios2/dts/.gitignore new file +1 -0
@@ -0,0 +1 @@ +*.dtb
arch/nios2/dts/3c120_devboard.dts new file +164 -0
164 lines not on this page · raw message
arch/nios2/dts/Makefile new file +11 -0
@@ -0,0 +1,11 @@ +dtb-y += 3c120_devboard.dtb + +targets += $(dtb-y) + +DTC_FLAGS += -R 4 -p 0x1000 + +PHONY += dtbs +dtbs: $(addprefix $(obj)/, $(dtb-y)) + @: + +clean-files := *.dtb
arch/nios2/dts/include/dt-bindings new file +1 -0
@@ -0,0 +1 @@ +../../../../include/dt-bindings
configs/nios2-generic_defconfig +2 -0
@@ -1,5 +1,6 @@ CONFIG_NIOS2=y CONFIG_TARGET_NIOS2_GENERIC=y +CONFIG_DEFAULT_DEVICE_TREE="3c120_devboard" CONFIG_HUSH_PARSER=y # CONFIG_CMD_BOOTD is not set # CONFIG_CMD_IMLS is not set
@@ -10,4 +11,5 @@ CONFIG_HUSH_PARSER=y CONFIG_CMD_DHCP=y # CONFIG_CMD_NFS is not set CONFIG_CMD_PING=y +CONFIG_OF_CONTROL=y CONFIG_NET_RANDOM_ETHADDR=y
Signature · 1 line
2.1.4
PATCH 2/5 nios2: enable device tree control of U-Boot
Hi Thomas,
Quoted 4 lines · Thomas Chou
This patch adds device tree control of U-Boot to nios2 boards. The example dts is taken from Linux kernel.
Signed-off-by Thomas Chou <[email protected]>
Quoted 12 lines
--- arch/nios2/dts/.gitignore | 1 + arch/nios2/dts/3c120_devboard.dts | 164 +++++++++++++++++++++++++++++++++++++ arch/nios2/dts/Makefile | 11 +++ arch/nios2/dts/include/dt-bindings | 1 + configs/nios2-generic_defconfig | 2 + 5 files changed, 179 insertions(+) create mode 100644 arch/nios2/dts/.gitignore create mode 100644 arch/nios2/dts/3c120_devboard.dts create mode 100644 arch/nios2/dts/Makefile create mode 120000 arch/nios2/dts/include/dt-bindings
But I think the license header should use SPDX.
Quoted 40 lines
arch/nios2/dts/.gitignore new file +1
-0@@ -0,0 +1 @@ +*.dtbarch/nios2/dts/3c120_devboard.dts new file +27
-0@@ -0,0 +1,164 @@ +/* + * Copyright (C) 2013 Altera Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * This file is generated by sopc2dts. + */ + +/dts-v1/; + +/ { + model = "altr,qsys_ghrd_3c120"; + compatible = "altr,qsys_ghrd_3c120"; + #address-cells = <1>; + #size-cells = <1>; +
[snip]
arch/nios2/dts/Makefile line 5
Quoted 11 lines
arch/nios2/dts/Makefile new file +5
-0@@ -0,0 +1,11 @@ +dtb-y += 3c120_devboard.dtb + +targets += $(dtb-y) + +DTC_FLAGS += -R 4 -p 0x1000
You can drop the -p 0x1000 part. It isn't needed.
Quoted 32 lines
arch/nios2/dts/Makefile new file +6
-0+ +PHONY += dtbs +dtbs: $(addprefix $(obj)/, $(dtb-y)) + @: + +clean-files := *.dtbarch/nios2/dts/include/dt-bindings new file +1
-0@@ -0,0 +1 @@ +../../../../include/dt-bindingsconfigs/nios2-generic_defconfig +2
-1@@ -1,5 +1,6 @@ CONFIG_NIOS2=y CONFIG_TARGET_NIOS2_GENERIC=y +CONFIG_DEFAULT_DEVICE_TREE="3c120_devboard" CONFIG_HUSH_PARSER=y # CONFIG_CMD_BOOTD is not set # CONFIG_CMD_IMLS is not set@@ -10,4 +11,5 @@ CONFIG_HUSH_PARSER=y CONFIG_CMD_DHCP=y # CONFIG_CMD_NFS is not set CONFIG_CMD_PING=y +CONFIG_OF_CONTROL=y CONFIG_NET_RANDOM_ETHADDR=y --
Quoted 2 lines
2.1.4
Regards,
Simon
PATCH 3/5 nios2: revert _end symbol in link script
In reply to Thomas ChouSince commit 44c6e6591cb451ae606f8bde71dd5fb7b4002544 "rename _end to __bss_end__" , the _end was removed. But we need it now for separated device tree control, ie, CONFIG_OF_SEPARATE .
Though _end used to be the end of u-boot.bin image, we mark it up and relocate the dtb part of u-boot-dtb.bin here to be used by fdtdec_setup().
--- arch/nios2/cpu/u-boot.lds | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
arch/nios2/cpu/u-boot.lds +13 -3
@@ -50,9 +50,10 @@ SECTIONS *(.gnu.linkonce.d*) } - . = ALIGN(16); - _gp = .; /* Global pointer addr */ - PROVIDE (gp = .); + /* gp - Since we don't use gp for small data with option "-G0", + * we will use gp as global data pointer. The _gp location is + * not needed. + */ .sdata : {
@@ -62,6 +63,9 @@ SECTIONS } . = ALIGN(4); + /* _edata - This is end of u-boot.bin image. + * dtb will be appended here to make u-boot-dtb.bin + */ _edata = .; PROVIDE (edata = .);
@@ -88,6 +92,12 @@ SECTIONS } . = ALIGN(4); __bss_end = .; + + /* _end - Though _end used to be the end of u-boot.bin image, + * we mark it up and relocate the dtb part of u-boot-dtb.bin here + * to be used by fdtdec_setup(). + */ + _end = .; PROVIDE (end = .); /* DEBUG -- symbol table, string table, etc. etc.
Signature · 1 line
2.1.4
PATCH 3/5 nios2: revert _end symbol in link script
Quoted 5 lines · Thomas Chou
Since commit
44c6e6591cb451ae606f8bde71dd5fb7b4002544"rename_endto__bss_end__" , the_endwas removed. But we need it now for separated device tree control, ie,CONFIG_OF_SEPARATE.
Quoted 8 lines
Though
_endused to be the end of u-boot.bin image, we mark it up and relocate the dtb part of u-boot-dtb.bin here to be used byfdtdec_setup().Signed-off-by Thomas Chou <[email protected]>--- arch/nios2/cpu/u-boot.lds | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
PATCH 4/5 nios2: initialize stack earlier in startup
In reply to Thomas ChouThis patch reorders the startup sequence, and initializes stack earlier. So that we can call external functions after stack initialized.
We will add OF control and use separated dtb. As dtb is located at the end of u-boot-dtb.bin image, we will need to relocate it before zeroing the bss. It will be easier to handle fdt in C than ASM.
--- arch/nios2/cpu/start.S | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-)
arch/nios2/cpu/start.S +22 -23
@@ -68,7 +68,7 @@ _except_end: _cur: movhi r5, %hi(_cur - _start) ori r5, r5, %lo(_cur - _start) sub r4, r4, r5 /* r4 <- cur _start */ - mov r8, r4 + mov r8, r4 /* r8 <- cur _start */ movhi r5, %hi(_start) ori r5, r5, %lo(_start) /* r5 <- linked _start */ beq r4, r5, 3f
@@ -82,26 +82,34 @@ _cur: movhi r5, %hi(_cur - _start) bne r5, r6, 2b 3: + /* JUMP TO RELOC ADDR */ + movhi r4, %hi(_reloc) + ori r4, r4, %lo(_reloc) + jmp r4 +_reloc: + + /* STACK INIT -- zero top two words for call back chain. */ + movhi sp, %hi(CONFIG_SYS_INIT_SP) + ori sp, sp, %lo(CONFIG_SYS_INIT_SP) + addi sp, sp, -8 + stw r0, 0(sp) + stw r0, 4(sp) + mov fp, sp + /* ZERO BSS/SBSS -- bss and sbss are assumed to be adjacent * and between __bss_start and __bss_end. */ - movhi r5, %hi(__bss_start) - ori r5, r5, %lo(__bss_start) - movhi r6, %hi(__bss_end) - ori r6, r6, %lo(__bss_end) - beq r5, r6, 5f + movhi r5, %hi(__bss_start) + ori r5, r5, %lo(__bss_start) + movhi r6, %hi(__bss_end) + ori r6, r6, %lo(__bss_end) + beq r5, r6, 5f 4: stwio r0, 0(r5) - addi r5, r5, 4 - bne r5, r6, 4b + addi r5, r5, 4 + bne r5, r6, 4b 5: - /* JUMP TO RELOC ADDR */ - movhi r4, %hi(_reloc) - ori r4, r4, %lo(_reloc) - jmp r4 -_reloc: - /* COPY EXCEPTION TRAMPOLINE -- copy the tramp to the * exception address. Define CONFIG_ROM_STUBS to prevent * the copy (e.g. exception in flash or in other
@@ -124,15 +132,6 @@ _reloc: 7: #endif - /* STACK INIT -- zero top two words for call back chain. - */ - movhi sp, %hi(CONFIG_SYS_INIT_SP) - ori sp, sp, %lo(CONFIG_SYS_INIT_SP) - addi sp, sp, -8 - stw r0, 0(sp) - stw r0, 4(sp) - mov fp, sp - /* * Call board_init_f -- never returns */
Signature · 1 line
2.1.4
PATCH 4/5 nios2: initialize stack earlier in startup
Hi Thomas,
Quoted 4 lines · Thomas Chou
This patch reorders the startup sequence, and initializes stack earlier. So that we can call external functions after stack initialized.
Quoted 8 lines
We will add OF control and use separated dtb. As dtb is located at the end of u-boot-dtb.bin image, we will need to relocate it before zeroing the bss. It will be easier to handle fdt in C than ASM.
Signed-off-by Thomas Chou <[email protected]>--- arch/nios2/cpu/start.S | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-)
Instead, is it possible to move to calling board_init_f_mem()?
Regards,
Simon
PATCH 5/5 nios2: relocate dtb for separated device tree
In reply to Thomas ChouThe relocation of nios2 is different. We will need to move dtb at the end of u-boot-dtb.bin image away from BSS sections. Otherwise it will be zeroed during startup.
--- arch/nios2/cpu/fdt.c | 20 +++++++++++++++++++- arch/nios2/cpu/start.S | 10 ++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-)
arch/nios2/cpu/fdt.c +19 -1
@@ -11,9 +11,11 @@*/ #include <common.h> +#include <libfdt.h> +#include <asm/sections.h> +#include <linux/ctype.h> #if defined(CONFIG_OF_LIBFDT ) && defined(CONFIG_OF_BOARD_SETUP ) -#include <libfdt.h> #include <fdt_support.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -36,3 +38,19 @@ void ft_cpu_setup(void *blob, bd_t *bd) fdt_fixup_ethernet(blob); }#endif /* CONFIG_OF_LIBFDT && CONFIG_OF_BOARD_SETUP */ + +#ifdef CONFIG_OF_SEPARATE +void relocate_dtb (ulong cur_start) +{ +/* This will be called from start.S . +* As dtb is located at the end of u-boot-dtb.bin image, +* we will need to relocate it before zeroing the bss. +* The dtb is moved from _edata to _end, which is markuped +* to __bss_end. Here _end will be used by fdtdec_setup(). +*/ +void *blob = (void *)(cur_start + (ulong )_edata - (ulong )_start); + +if (fdt_magic (blob) ==FDT_MAGIC ) +memmove (_end, blob,fdt_totalsize (blob)); +} +#endif /* CONFIG_OF_SEPARATE */
arch/nios2/cpu/start.S +10 -0
@@ -96,6 +96,16 @@ _reloc: stw r0, 4(sp) mov fp, sp +#ifdef CONFIG_OF_SEPARATE + /* RELOCATE DTB -- relocate dtb in u-boot-dtb.bin image + * to be used by fdtdec_setup(). + */ + mov r4, r8 /* r8 <- cur _start */ + movhi r2, %hi(relocate_dtb at h) + ori r2, r2, %lo(relocate_dtb@h) + callr r2 +#endif + /* ZERO BSS/SBSS -- bss and sbss are assumed to be adjacent * and between __bss_start and __bss_end. */
Signature · 1 line
2.1.4
PATCH 5/5 nios2: relocate dtb for separated device tree
+Marek
Hi Thomas,
Quoted 9 lines · Thomas Chou
The relocation of nios2 is different. We will need to move dtb at the end of u-boot-dtb.bin image away from BSS sections. Otherwise it will be zeroed during startup.
Signed-off-by Thomas Chou <[email protected]>--- arch/nios2/cpu/fdt.c | 20 +++++++++++++++++++- arch/nios2/cpu/start.S | 10 ++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-)
Can you help me understand the relocation a bit? There is already code in board_init_f() to relocate the device tree, and until board_init_r(), BSS should not be used. What is different about NIOS?
Quoted 60 lines
arch/nios2/cpu/fdt.c +19
-1@@ -11,9 +11,11 @@*/ #include <common.h> +#include <libfdt.h> +#include <asm/sections.h> +#include <linux/ctype.h> #if defined(CONFIG_OF_LIBFDT ) && defined(CONFIG_OF_BOARD_SETUP ) -#include <libfdt.h> #include <fdt_support.h> DECLARE_GLOBAL_DATA_PTR ;@@ -36,3 +38,19 @@ void ft_cpu_setup(void *blob, bd_t *bd) fdt_fixup_ethernet(blob); }#endif /* CONFIG_OF_LIBFDT && CONFIG_OF_BOARD_SETUP */ + +#ifdef CONFIG_OF_SEPARATE +void relocate_dtb (ulong cur_start) +{ +/* This will be called from start.S . +* As dtb is located at the end of u-boot-dtb.bin image, +* we will need to relocate it before zeroing the bss. +* The dtb is moved from _edata to _end, which is markuped +* to __bss_end. Here _end will be used by fdtdec_setup(). +*/ +void *blob = (void *)(cur_start + (ulong )_edata - (ulong )_start); + +if (fdt_magic (blob) ==FDT_MAGIC ) +memmove (_end, blob,fdt_totalsize (blob)); +} +#endif /* CONFIG_OF_SEPARATE */ arch/nios2/cpu/start.S +10
-1@@ -96,6 +96,16 @@ _reloc: stw r0, 4(sp) mov fp, sp +#ifdef CONFIG_OF_SEPARATE + /* RELOCATE DTB -- relocate dtb in u-boot-dtb.bin image + * to be used by fdtdec_setup(). + */ + mov r4, r8 /* r8 <- cur _start */ + movhi r2, %hi(relocate_dtb at h) + ori r2, r2, %lo(relocate_dtb at h) + callr r2 +#endif + /* ZERO BSS/SBSS -- bss and sbss are assumed to be adjacent * and between __bss_start and __bss_end. */ --
Quoted 2 lines
2.1.4
Regards,
Simon
PATCH 5/5 nios2: relocate dtb for separated device tree
Hi Simon,
Quoted 3 lines · Simon Glass
Can you help me understand the relocation a bit? There is already code in
board_init_f()to relocate the device tree, and untilboard_init_r(), BSS should not be used. What is different about NIOS?
Thank you for the comment. I think the problem is in the current nios2 startup code start.S. The BSS is cleared before board_init_f(). I will rework the startup code to make use of the board_init code.
Best regards,
Thomas Chou
v2 cover nios2: add device tree control of U-Boot
In reply to Thomas ChouThese patches add device tree control of U-Boot to nios2 boards.
v2
use SPDX license header.
use fdt relocation in board_init_f.
Thomas Chou (8):
nios2: permit device tree control of U-Boot
nios2: move altera_pio_init to board_early_init_r
nios2: BSS should be cleared only after board_init_f
nios2: enlarge the code relocation range
nios2: remove gp assignments in link script
nios2: define _end in link script
nios2: show fdt blob address in board info command
nios2: enable device tree control of U-Boot
arch/Kconfig | 1 + arch/nios2/cpu/start.S | 34 ++++--- arch/nios2/cpu/u-boot.lds | 12 ++- arch/nios2/dts/.gitignore | 1 + arch/nios2/dts/3c120_devboard.dts | 153 +++++++++++++++++++++++++++++ arch/nios2/dts/Makefile | 11 +++ arch/nios2/dts/include/dt-bindings | 1 + board/altera/nios2-generic/nios2-generic.c | 13 ++- common/cmd_bdinfo.c | 3 + configs/nios2-generic_defconfig | 2 + include/configs/nios2-generic.h | 1 + 11 files changed, 209 insertions(+), 23 deletions(-) create mode 100644 arch/nios2/dts/.gitignore create mode 100644 arch/nios2/dts/3c120_devboard.dts create mode 100644 arch/nios2/dts/Makefile create mode 120000 arch/nios2/dts/include/dt-bindings
Signature · 1 line
2.1.4
PATCH v2 1/8 nios2: permit device tree control of U-Boot
Enable this in the Kconfig so that nios2 boards can use device tree to configure U-Boot.
--- arch/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/Kconfig +1 -0
@@ -63,6 +63,7 @@ config NIOS2 bool "Nios II architecture" select HAVE_GENERIC_BOARD select SYS_GENERIC_BOARD + select SUPPORT_OF_CONTROL config OPENRISC bool "OpenRISC architecture"
Signature · 1 line
2.1.4
PATCH v2 1/8 nios2: permit device tree control of U-Boot
Quoted 5 lines · Thomas Chou
Enable this in the
Kconfigso that nios2 boards can use device tree to configure U-Boot.Signed-off-by Thomas Chou <[email protected]>Reviewed-by Simon Glass <[email protected]>
Best regards,
Marek Vasut
PATCH v2 2/8 nios2: move altera_pio_init to board_early_init_r
In reply to Thomas ChouAs altera_pio_init() uses BSS, it should be moved to board_early_init_r().
--- board/altera/nios2-generic/nios2-generic.c | 13 +++++++++---- include/configs/nios2-generic.h | 1 + 2 files changed, 10 insertions(+), 4 deletions(-)
board/altera/nios2-generic/nios2-generic.c +9 -4
@@ -28,6 +28,15 @@ void early_flash_cmd_reset(void)int board_early_init_f (void ) { +#if defined(CONFIG_ENV_IS_IN_FLASH ) && defined(CONFIG_ENV_ADDR ) && \ + defined(CONFIG_CFI_FLASH_MTD ) +early_flash_cmd_reset (); +#endif +return 0 ; +} + +int board_early_init_r (void ) +{#ifdef CONFIG_ALTERA_PIO #ifdef LED_PIO_BASE altera_pio_init(LED_PIO_BASE, LED_PIO_WIDTH, 'o',
@@ -35,10 +44,6 @@ int board_early_init_f(void) "led");#endif #endif -#if defined(CONFIG_ENV_IS_IN_FLASH ) && defined(CONFIG_ENV_ADDR ) && \ - defined(CONFIG_CFI_FLASH_MTD ) -early_flash_cmd_reset (); -#endif return 0 ; }
include/configs/nios2-generic.h +1 -0
@@ -15,6 +15,7 @@#include "../board/altera/nios2-generic/custom_fpga.h" /* fpga parameters */ #define CONFIG_BOARD_NAME "nios2-generic"/* custom board name */ #define CONFIG_BOARD_EARLY_INIT_F /* enable early board-spec. init */ +#define CONFIG_BOARD_EARLY_INIT_R #define CONFIG_DISPLAY_CPUINFO #define CONFIG_DISPLAY_BOARDINFO #define CONFIG_SYS_NIOS_SYSID_BASE CONFIG_SYS_SYSID_BASE
Signature · 1 line
2.1.4
PATCH v2 2/8 nios2: move altera_pio_init to board_early_init_r
Quoted 4 lines · Thomas Chou
As
altera_pio_init()uses BSS, it should be moved toboard_early_init_r().Signed-off-by Thomas Chou <[email protected]>
Shouldn't this be part of arch_cpu_init() instead ?
Best regards,
Marek Vasut
PATCH v2 2/8 nios2: move altera_pio_init to board_early_init_r
Hi Marek,
Quoted 7 lines · Marek Vasut
Quoted 4 lines · Thomas Chou
As
altera_pio_init()uses BSS, it should be moved toboard_early_init_r().Signed-off-by Thomas Chou <[email protected]>Shouldn't this be part of
arch_cpu_init()instead ?
This is per board setup. Each board might has a different PIO configuration.
Regards,
Thomas Chou
PATCH v2 2/8 nios2: move altera_pio_init to board_early_init_r
Quoted 7 lines · Thomas Chou
Hi Marek,
Quoted 4 lines · Marek Vasut
Quoted 3 lines · Thomas Chou
As
altera_pio_init()uses BSS, it should be moved toboard_early_init_r().
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Thomas Chou <[email protected]>Shouldn't this be part of
arch_cpu_init()instead ?This is per board setup. Each board might has a different PIO configuration.
OK, I see what you're doing here now. I agree.
Best regards,
Marek Vasut
PATCH v2 3/8 nios2: BSS should be cleared only after board_init_f
In reply to Thomas ChouAs dtb in u-boot-dtb.bin overlapped the BSS section, we should delay the clearing of BSS until dtb is relocated in board_init_f().
--- arch/nios2/cpu/start.S | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-)
arch/nios2/cpu/start.S +15 -14
@@ -82,20 +82,6 @@ _cur: movhi r5, %hi(_cur - _start) bne r5, r6, 2b 3: - /* ZERO BSS/SBSS -- bss and sbss are assumed to be adjacent - * and between __bss_start and __bss_end. - */ - movhi r5, %hi(__bss_start) - ori r5, r5, %lo(__bss_start) - movhi r6, %hi(__bss_end) - ori r6, r6, %lo(__bss_end) - beq r5, r6, 5f - -4: stwio r0, 0(r5) - addi r5, r5, 4 - bne r5, r6, 4b -5: - /* JUMP TO RELOC ADDR */ movhi r4, %hi(_reloc) ori r4, r4, %lo(_reloc)
@@ -167,6 +153,21 @@ _reloc: relocate_code: mov sp, r4 /* Set the new sp */ mov r4, r5 + + /* ZERO BSS/SBSS -- bss and sbss are assumed to be adjacent + * and between __bss_start and __bss_end. + */ + movhi r5, %hi(__bss_start) + ori r5, r5, %lo(__bss_start) + movhi r6, %hi(__bss_end) + ori r6, r6, %lo(__bss_end) + beq r5, r6, 5f + +4: stwio r0, 0(r5) + addi r5, r5, 4 + bne r5, r6, 4b +5: + movhi r8, %hi(board_init_r at h) ori r8, r8, %lo(board_init_r at h) callr r8
Signature · 1 line
2.1.4
PATCH v2 3/8 nios2: BSS should be cleared only after board_init_f
Quoted 5 lines · Thomas Chou
As dtb in u-boot-dtb.bin overlapped the BSS section, we should delay the clearing of BSS until dtb is relocated in
board_init_f().Signed-off-by Thomas Chou <[email protected]>
Best regards,
Marek Vasut
PATCH v2 4/8 nios2: enlarge the code relocation range
In reply to Thomas ChouAs we will use u-boot-dtb.bin, the code relocation range should be adjusted to accommodate the additional dtb. It might be overkilled to look into dtb header to find the dtb size, so we will simply use CONFIG_SYS_MONITOR_LEN.
--- arch/nios2/cpu/start.S | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/nios2/cpu/start.S +3 -2
@@ -73,8 +73,9 @@ _cur: movhi r5, %hi(_cur - _start) ori r5, r5, %lo(_start) /* r5 <- linked _start */ beq r4, r5, 3f - movhi r6, %hi(_edata) - ori r6, r6, %lo(_edata) + movhi r6, %hi(CONFIG_SYS_MONITOR_LEN) + ori r6, r6, %lo(CONFIG_SYS_MONITOR_LEN) + add r6, r6, r5 2: ldwio r7, 0(r4) addi r4, r4, 4 stwio r7, 0(r5)
Signature · 1 line
2.1.4
PATCH v2 4/8 nios2: enlarge the code relocation range
Quoted 16 lines · Thomas Chou
As we will use u-boot-dtb.bin, the code relocation range should be adjusted to accommodate the additional dtb. It might be overkilled to look into dtb header to find the dtb size, so we will simply use
CONFIG_SYS_MONITOR_LEN.Signed-off-by Thomas Chou <[email protected]>--- arch/nios2/cpu/start.S | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)arch/nios2/cpu/start.S +0
-0@@ -73,8 +73,9 @@ _cur: movhi r5, %hi(_cur - _start) ori r5, r5, %lo(_start) /* r5 <- linked _start */
arch/nios2/cpu/start.S _cur: movhi r5, %hi(_cur - _start) · line 81
Quoted 10 lines
arch/nios2/cpu/start.S +3
-2beq r4, r5, 3f - movhi r6, %hi(_edata) - ori r6, r6, %lo(_edata) + movhi r6, %hi(CONFIG_SYS_MONITOR_LEN) + ori r6, r6, %lo(CONFIG_SYS_MONITOR_LEN) + add r6, r6, r5 2: ldwio r7, 0(r4) addi r4, r4, 4 stwio r7, 0(r5)
Can't you just call relocate_code the same way arm does it in arch/arm/lib/crt0.S ?
Best regards,
Marek Vasut
PATCH v2 4/8 nios2: enlarge the code relocation range
Hi Marek,
Quoted 2 lines · Marek Vasut
Can't you just call
relocate_codethe same way arm does it inarch/arm/lib/crt0.S?
We didn't include relocation records in nios2 binary image, so there is no real relocation like that of ARM.
Altera provides small boot loaders for cfi/sf along with their nios2 jtag flash programmer, which will load the image to the linked address in sdram. The relocating loop in start.S works only if such Altera boot loader is not used, ie, booting directly from cfi flash.
Best regards,
Thomas Chou
PATCH v2 4/8 nios2: enlarge the code relocation range
Quoted 1 line · Thomas Chou
Hi Marek,
Hi,
Quoted 6 lines · Marek Vasut
Quoted 2 lines
Can't you just call
relocate_codethe same way arm does it inarch/arm/lib/crt0.S?We didn't include relocation records in nios2 binary image, so there is no real relocation like that of ARM.
Can we add them instead ?
Quoted 4 lines
Altera provides small boot loaders for cfi/sf along with their nios2 jtag flash programmer, which will load the image to the linked address in sdram. The relocating loop in
start.Sworks only if such Altera boot loader is not used, ie, booting directly from cfi flash.
Hm, Im not using the Altera loader :)
Best regards,
Marek Vasut
PATCH v2 4/8 nios2: enlarge the code relocation range
HI Marek,
Quoted 4 lines · Marek Vasut
Quoted 2 lines
We didn't include relocation records in nios2 binary image, so there is no real relocation like that of ARM.
Can we add them instead ?
I think it is possible. I recalled that we have an old flat image format with elf2flt to run nonmmu uclinux, which does a similar relocation. But I would suggest that we should keep thing simple and small in a boot loader like U-Boot.
Quoted 8 lines
Quoted 5 lines
Altera provides small boot loaders for cfi/sf along with their nios2 jtag flash programmer, which will load the image to the linked address in sdram. The relocating loop in
start.Sworks only if such Altera boot loader is not used, ie, booting directly from cfi flash.Hm, Im not using the Altera loader :)
Neither am I. Look like we all use custom boot copiers, and we don't need the relocation in the patch above. It doesn't make sense to copy the code twice. Right? :)
Best regards
Thomas Chou
PATCH v2 4/8 nios2: enlarge the code relocation range
Quoted 1 line · Thomas Chou
HI Marek,
Hi!
Quoted 10 lines · Marek Vasut
Quoted 4 lines
Quoted 2 lines
We didn't include relocation records in nios2 binary image, so there is no real relocation like that of ARM.
Can we add them instead ?
I think it is possible. I recalled that we have an old flat image format with elf2flt to run nonmmu uclinux, which does a similar relocation. But I would suggest that we should keep thing simple and small in a boot loader like U-Boot.
We already do it on ARM though and the reason for this is to place U-Boot at the end of the DRAM, so that most of the DRAM can be used by the user.
Quoted 10 lines
Quoted 6 lines
Quoted 4 lines
Altera provides small boot loaders for cfi/sf along with their nios2 jtag flash programmer, which will load the image to the linked address in sdram. The relocating loop in
start.Sworks only if such Altera boot loader is not used, ie, booting directly from cfi flash.Hm, Im not using the Altera loader :)
Neither am I. Look like we all use custom boot copiers, and we don't need the relocation in the patch above. It doesn't make sense to copy the code twice. Right? :)
In fact, I am loading U-Boot with GDB thus far, so I am only copying it once ;-) Where is the second copying coming from ?
Best regards,
Marek Vasut
PATCH v2 4/8 nios2: enlarge the code relocation range
Hi Marek,
Quoted 2 lines · Marek Vasut
We already do it on ARM though and the reason for this is to place U-Boot at the end of the DRAM, so that most of the DRAM can be used by the user.
We place U-Boot at the end of the DRAM on nios2, too. :)
I will look into the relocation on nios2 next time. But for now, I would suggest that we skip this and move on to driver model.
Quoted 2 lines
In fact, I am loading U-Boot with GDB thus far, so I am only copying it once ;-) Where is the second copying coming from ?
That was true for gdb. But when you need to try out u-boot-dtb.bin on EPCS/sf, it will be another story..
Best regards,
Thomas Chou
PATCH v2 4/8 nios2: enlarge the code relocation range
Quoted 1 line · Thomas Chou
Hi Marek,
Hi,
Quoted 8 lines · Marek Vasut
Quoted 2 lines
We already do it on ARM though and the reason for this is to place U-Boot at the end of the DRAM, so that most of the DRAM can be used by the user.
We place U-Boot at the end of the DRAM on nios2, too. :)
I will look into the relocation on nios2 next time. But for now, I would suggest that we skip this and move on to driver model.
These two things are orthogonal, so no problem :)
Quoted 5 lines
Quoted 2 lines
In fact, I am loading U-Boot with GDB thus far, so I am only copying it once ;-) Where is the second copying coming from ?
That was true for gdb. But when you need to try out u-boot-dtb.bin on EPCS/sf, it will be another story..
Why so? The EPCS is memory mapped and U-Boot starts from it, right ? So U-Boot can relocate itself to the end of DRAM , right ?
Best regards,
Marek Vasut
PATCH v2 4/8 nios2: enlarge the code relocation range
Hi Marek,
Quoted 2 lines · Marek Vasut
Why so? The EPCS is memory mapped and U-Boot starts from it, right ? So U-Boot can relocate itself to the end of DRAM , right ?
No. EPCS contains a default boot copier which I said earlier.
Please take a look at this,
Though the default EPCS boot copier works, it is not easy to update u-boot(-dtb).bin image with u-boot sf command. So I used a modified version, which copies the u-boot image from a fixed location on EPCS/sf to the end of DRAM.
Best regards,
Thomas Chou
PATCH v2 4/8 nios2: enlarge the code relocation range
Quoted 1 line · Thomas Chou
Hi Marek,
Hi,
Quoted 8 lines · Marek Vasut
Quoted 2 lines
Why so? The EPCS is memory mapped and U-Boot starts from it, right ? So U-Boot can relocate itself to the end of DRAM , right ?
No. EPCS contains a default boot copier which I said earlier.
Please take a look at this,
Quoted 7 lines
https://www.altera.com/support/support-resources/design-examples/intellectu
al-property/embedded/nios-ii/exm-alt-boot-methods.htmlThough the default EPCS boot copier works, it is not easy to update u-boot(-dtb).bin image with u-boot sf command. So I used a modified version, which copies the u-boot image from a fixed location on EPCS/sf to the end of DRAM.
Uh oh, is this copying something the U-Boot SPL cannot do for us ?
Sorry, I might be a bit lost in the "official" ways because I'm too used to mainline ;-)
Best regards,
Marek Vasut
PATCH v2 4/8 nios2: enlarge the code relocation range
Hi Marek,
Quoted 1 line · Marek Vasut
Uh oh, is this copying something the U-Boot SPL cannot do for us ?
Though U-Boot SPL can do, it will need 64KB onchip memory. While the EPCS controller needs only 512B onchip memory. So we didn't ever consider SPL for nios2.
Best regards,
Thomas Chou
PATCH v2 4/8 nios2: enlarge the code relocation range
Quoted 1 line · Thomas Chou
Hi Marek,
Hi!
Quoted 6 lines · Marek Vasut
Quoted 1 line
Uh oh, is this copying something the U-Boot SPL cannot do for us ?
Though U-Boot SPL can do, it will need 64KB onchip memory. While the EPCS controller needs only 512B onchip memory. So we didn't ever consider SPL for nios2.
Where did that 64KB figure come from ? :O
I assume the simple loader is just a copy loop, huh ? And you synthesise a small RAM or ROM into the FPGA and point NIOS to boot from that, right? What about U-Boot TPL, can that cook the loader ? (yes, I'd like to be as independent of the external code as possible).
Best regards,
Marek Vasut
PATCH v2 4/8 nios2: enlarge the code relocation range
Hi Marek,
Quoted 1 line · Marek Vasut
Where did that 64KB figure come from ? :O
This is estimated from 41KB of the SPL of socfpga. The code density of nios2 is worse than ARM.
Quoted 2 lines
I assume the simple loader is just a copy loop, huh ? And you synthesise a small RAM or ROM into the FPGA and point NIOS to boot from that, right?
Right. It is hidden from the user in qsys. You will need to dig into the code to find out. The EPCS boot copier is coded in nios2 ASM.
Quoted 2 lines
What about U-Boot TPL, can that cook the loader ? (yes, I'd like to be as independent of the external code as possible).
I'd like to be independent of the external code, too. In the past, I have my own SPI core (now the oc_tiny_spi) to control EPCS, which is actually SPI flash, and my own boot copier with/out decompression.
It is possible to add an TPL support for nios2 EPCS. If someone want to work on it.. :)
Best regards,
Thomas Chou
PATCH v2 4/8 nios2: enlarge the code relocation range
Quoted 1 line · Thomas Chou
Hi Marek,
Hi!
Quoted 11 lines · Marek Vasut
Quoted 1 line
Where did that 64KB figure come from ? :O
This is estimated from 41KB of the SPL of socfpga. The code density of nios2 is worse than ARM.
Quoted 2 lines
I assume the simple loader is just a copy loop, huh ? And you synthesise a small RAM or ROM into the FPGA and point NIOS to boot from that, right?
Right. It is hidden from the user in qsys. You will need to dig into the code to find out. The EPCS boot copier is coded in nios2 ASM.
Oh, I see.
Quoted 9 lines
Quoted 2 lines
What about U-Boot TPL, can that cook the loader ? (yes, I'd like to be as independent of the external code as possible).
I'd like to be independent of the external code, too. In the past, I have my own SPI core (now the
oc_tiny_spi) to control EPCS, which is actually SPI flash, and my own boot copier with/out decompression.It is possible to add an TPL support for nios2 EPCS. If someone want to work on it.. :)
I'll keep this in mind, thanks :)
Best regards,
Marek Vasut
PATCH v2 5/8 nios2: remove gp assignments in link script
In reply to Thomas ChouSince we don't use gp for small data with option "-G0", we use gp as global data pointer. The _gp location is not needed.
The ALIGN(16) was for gp only. It is removed, so that we can get correct address of dtb in u-boot-dtb.bin image.
--- arch/nios2/cpu/u-boot.lds | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
arch/nios2/cpu/u-boot.lds +4 -3
@@ -50,9 +50,10 @@ SECTIONS *(.gnu.linkonce.d*) } - . = ALIGN(16); - _gp = .; /* Global pointer addr */ - PROVIDE (gp = .); + /* gp - Since we don't use gp for small data with option "-G0", + * we will use gp as global data pointer. The _gp location is + * not needed. + */ .sdata : {
Signature · 1 line
2.1.4
PATCH v2 5/8 nios2: remove gp assignments in link script
Quoted 17 lines · Thomas Chou
Since we don't use gp for small data with option "-G0", we use gp as global data pointer. The
_gplocation is not needed.The ALIGN(16) was for gp only. It is removed, so that we can get correct address of dtb in u-boot-dtb.bin image.
Signed-off-by Thomas Chou <[email protected]>--- arch/nios2/cpu/u-boot.lds | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)arch/nios2/cpu/u-boot.lds +0
-0
arch/nios2/cpu/u-boot.lds SECTIONS · line 53
Quoted 7 lines
arch/nios2/cpu/u-boot.lds +1
-3@@ -50,9 +50,10 @@ SECTIONS *(.gnu.linkonce.d*) } - . = ALIGN(16); - _gp = .; /* Global pointer addr */ - PROVIDE (gp = .); + /* gp - Since we don't use gp for small data with option "-G0",
Please make the multiline comment match the kernel coding style:
/*
* foo
* bar
*/
Otherwise
arch/nios2/cpu/u-boot.lds SECTIONS · line 59
Quoted 6 lines
arch/nios2/cpu/u-boot.lds +3
-0+ * we will use gp as global data pointer. The _gp location is + * not needed. + */ .sdata : {
Best regards,
Marek Vasut
PATCH v3 5/8 nios2: remove gp assignments in link script
Since we don't use gp for small data with option "-G0", we use gp as global data pointer. The _gp location is not needed.
The ALIGN(16) was for gp only. It is removed, so that we can get correct address of dtb in u-boot-dtb.bin image.
---
v3 comment coding style fix
arch/nios2/cpu/u-boot.lds | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
arch/nios2/cpu/u-boot.lds +5 -3
@@ -50,9 +50,11 @@ SECTIONS *(.gnu.linkonce.d*) } - . = ALIGN(16); - _gp = .; /* Global pointer addr */ - PROVIDE (gp = .); + /* + * gp - Since we don't use gp for small data with option "-G0", + * we will use gp as global data pointer. The _gp location is + * not needed. + */ .sdata : {
Signature · 1 line
2.1.4
PATCH v2 6/8 nios2: define _end in link script
In reply to Thomas ChouSince commit 44c6e6591cb451ae606f8bde71dd5fb7b4002544 "rename _end to __bss_end__" , the _end was removed. But we need it now for separated device tree control, ie, CONFIG_OF_SEPARATE .
The _end is used by fdtdec_setup() to find the blob.
--- arch/nios2/cpu/u-boot.lds | 5 +++++ 1 file changed, 5 insertions(+)
arch/nios2/cpu/u-boot.lds +5 -0
@@ -66,6 +66,11 @@ SECTIONS _edata = .; PROVIDE (edata = .); + /* _end - This is end of u-boot.bin image. + * dtb will be appended here to make u-boot-dtb.bin + */ + _end = .; + /* UNINIT DATA - Small uninitialized data is first so it's * adjacent to sdata and can be referenced via gp. The normal * bss follows. We keep it adjacent to simplify init code.
Signature · 1 line
2.1.4
PATCH v2 6/8 nios2: define _end in link script
Quoted 17 lines · Thomas Chou
Since commit
44c6e6591cb451ae606f8bde71dd5fb7b4002544"rename_endto__bss_end__" , the_endwas removed. But we need it now for separated device tree control, ie,CONFIG_OF_SEPARATE.The
_endis used byfdtdec_setup()to find the blob.Signed-off-by Thomas Chou <[email protected]>--- arch/nios2/cpu/u-boot.lds | 5 +++++ 1 file changed, 5 insertions(+)arch/nios2/cpu/u-boot.lds +0
-0
arch/nios2/cpu/u-boot.lds SECTIONS · line 72
Quoted 7 lines
arch/nios2/cpu/u-boot.lds +4
-0@@ -66,6 +66,11 @@ SECTIONS _edata = .; PROVIDE (edata = .); + /* _end - This is end of u-boot.bin image. + * dtb will be appended here to make u-boot-dtb.bin + */ + _end = .;
Same comment about the comment as in the previous patch, but otherwise:
arch/nios2/cpu/u-boot.lds SECTIONS · line 76
Quoted 3 lines
arch/nios2/cpu/u-boot.lds +0
-0/* UNINIT DATA - Small uninitialized data is first so it's * adjacent to sdata and can be referenced via gp. The normal * bss follows. We keep it adjacent to simplify init code.
Best regards,
Marek Vasut
PATCH v3 6/8 nios2: define _end in link script
Since commit 44c6e6591cb451ae606f8bde71dd5fb7b4002544 "rename _end to __bss_end__" , the _end was removed. But we need it now for separated device tree control, ie, CONFIG_OF_SEPARATE .
The _end is used by fdtdec_setup() to find the blob.
---
v3 comment coding style fix
arch/nios2/cpu/u-boot.lds | 6 ++++++ 1 file changed, 6 insertions(+)
arch/nios2/cpu/u-boot.lds +6 -0
@@ -67,6 +67,12 @@ SECTIONS _edata = .; PROVIDE (edata = .); + /* + * _end - This is end of u-boot.bin image. + * dtb will be appended here to make u-boot-dtb.bin + */ + _end = .; + /* UNINIT DATA - Small uninitialized data is first so it's * adjacent to sdata and can be referenced via gp. The normal * bss follows. We keep it adjacent to simplify init code.
Signature · 1 line
2.1.4
PATCH v3 6/8 nios2: define _end in link script
Quoted 22 lines · Thomas Chou
Since commit
44c6e6591cb451ae606f8bde71dd5fb7b4002544"rename_endto__bss_end__" , the_endwas removed. But we need it now for separated device tree control, ie,CONFIG_OF_SEPARATE.The
_endis used byfdtdec_setup()to find the blob.Signed-off-by Thomas Chou <[email protected]>Acked-by Marek Vasut <[email protected]>Reviewed-by Simon Glass <[email protected]>---
v3 comment coding style fix
arch/nios2/cpu/u-boot.lds | 6 ++++++ 1 file changed, 6 insertions(+)arch/nios2/cpu/u-boot.lds +0
-0
arch/nios2/cpu/u-boot.lds SECTIONS · line 73
Quoted 7 lines
arch/nios2/cpu/u-boot.lds +4
-0@@ -67,6 +67,12 @@ SECTIONS _edata = .; PROVIDE (edata = .); + /* + * _end - This is end of u-boot.bin image. + * dtb will be appended here to make u-boot-dtb.bin + */
Still broken ;-)
btw. please either repost the whole series or use git send-email --in-reply-to , so I dont have to hunt down patches all over the place.
arch/nios2/cpu/u-boot.lds SECTIONS · line 78
Quoted 5 lines
arch/nios2/cpu/u-boot.lds +2
-0+ _end = .; + /* UNINIT DATA - Small uninitialized data is first so it's * adjacent to sdata and can be referenced via gp. The normal * bss follows. We keep it adjacent to simplify init code.
Best regards,
Marek Vasut
PATCH v2 6/8 nios2: define _end in link script
In reply to Thomas ChouHi Thomas,
Quoted 11 lines · Thomas Chou
Since commit
44c6e6591cb451ae606f8bde71dd5fb7b4002544"rename_endto__bss_end__" , the_endwas removed. But we need it now for separated device tree control, ie,CONFIG_OF_SEPARATE.The
_endis used byfdtdec_setup()to find the blob.Signed-off-by Thomas Chou <[email protected]>--- arch/nios2/cpu/u-boot.lds | 5 +++++ 1 file changed, 5 insertions(+)
arch/nios2/cpu/u-boot.lds SECTIONS · line 69
Quoted 10 lines
arch/nios2/cpu/u-boot.lds +1
-0@@ -66,6 +66,11 @@ SECTIONS _edata = .; PROVIDE (edata = .); + /* _end - This is end of u-boot.bin image.
comment style:
/*
* _end -
Quoted 10 lines
arch/nios2/cpu/u-boot.lds +4
-1+ * dtb will be appended here to make u-boot-dtb.bin + */ + _end = .; + /* UNINIT DATA - Small uninitialized data is first so it's * adjacent to sdata and can be referenced via gp. The normal * bss follows. We keep it adjacent to simplify init code. --2.1.4
Regards,
Simon
PATCH v2 7/8 nios2: show fdt blob address in board info command
In reply to Thomas ChouShow fdt blob address in board info command.
--- common/cmd_bdinfo.c | 3 +++ 1 file changed, 3 insertions(+)
common/cmd_bdinfo.c +3 -0
@@ -176,6 +176,9 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])#endif printf ("baudrate = %u bps\n" , gd->baudrate); +#if defined(CONFIG_OF_CONTROL ) +print_num ("fdt_blob" , (ulong )gd->fdt_blob); +#endif return 0 ; }
Signature · 1 line
2.1.4
PATCH v2 7/8 nios2: show fdt blob address in board info command
Quoted 14 lines · Thomas Chou
Show fdt blob address in board info command.
Signed-off-by Thomas Chou <[email protected]>--- common/cmd_bdinfo.c | 3 +++ 1 file changed, 3 insertions(+)common/cmd_bdinfo.c +0
-0@@ -176,6 +176,9 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc,char * const argv[]) #endif
common/cmd_bdinfo.c int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 180
Quoted 3 lines
common/cmd_bdinfo.c +2
-0printf ("baudrate = %u bps\n" , gd->baudrate); +#if defined(CONFIG_OF_CONTROL ) +print_num ("fdt_blob" , (ulong )gd->fdt_blob);
I think this will not work on 64bit machines.
common/cmd_bdinfo.c int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 184
Quoted 4 lines
common/cmd_bdinfo.c +1
-0+#endif return 0 ; }
Best regards,
Marek Vasut
PATCH v2 7/8 nios2: show fdt blob address in board info command
Hi Marek,
Quoted 3 lines · Marek Vasut
common/cmd_bdinfo.c int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 180
Quoted 1 line
common/cmd_bdinfo.c +1
-0+print_num ("fdt_blob" , (ulong )gd->fdt_blob);I think this will not work on 64bit machines.
I'd agree that it won't work on 64bits machines, but it is enough for a soft-core 32btis fpga processor. :)
Best regards,
Thomas Chou
PATCH v2 7/8 nios2: show fdt blob address in board info command
Quoted 1 line · Thomas Chou
Hi Marek,
Hi,
Quoted 7 lines · Marek Vasut
Quoted 3 lines
common/cmd_bdinfo.c int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 180
Quoted 1 line
common/cmd_bdinfo.c +1
-0+print_num ("fdt_blob" , (ulong )gd->fdt_blob);I think this will not work on 64bit machines.
I'd agree that it won't work on 64bits machines, but it is enough for a soft-core 32btis fpga processor. :)
That's a common code you're modifying, so it has to be done right, sorry, this patch cannot be accepted in this form.
Best regards,
Marek Vasut
PATCH v2 7/8 nios2: show fdt blob address in board info command
Hi Marek,
Quoted 2 lines · Marek Vasut
That's a common code you're modifying, so it has to be done right, sorry, this patch cannot be accepted in this form.
I understand. I will use (u64) and print_lnum().
Best regards,
Thomas Chou
PATCH v2 7/8 nios2: show fdt blob address in board info command
In reply to Marek VasutHi Marek,
Quoted 1 line
Quoted 1 line
Quoted 1 line
I think this will not work on 64bit machines.
I tried 64bits with
print_lnum("fdt_blob", (u64)gd->fdt_blob);But got this warning,
CC common/cmd_bdinfo.ocommon/cmd_bdinfo.c: In function 'do_bdinfo':common/cmd_bdinfo.c:180:25: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
print_lnum("fdt_blob", (u64)gd->fdt_blob);
^include/asm-generic/global_data.h
const void *fdt_blob; /* Our device tree, NULL if none */
Actually, the print is guarded with CONFIG_NIOS2, so it is safe to use 32bits.
Or shall we invent a "print pointer address"?
Best regards,
Thomas Chou
PATCH v2 7/8 nios2: show fdt blob address in board info command
Quoted 16 lines · Thomas Chou
Hi Marek,
Quoted 1 line
Quoted 1 line
Quoted 1 line
I think this will not work on 64bit machines.
I tried 64bits with
print_lnum("fdt_blob", (u64)gd->fdt_blob);But got this warning,
CC
common/cmd_bdinfo.ocommon/cmd_bdinfo.c: In function 'do_bdinfo':common/cmd_bdinfo.c:180:25: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]print_lnum("fdt_blob", (u64)gd->fdt_blob); ^
Quoted 7 lines
include/asm-generic/global_data.h
const void*fdt_blob; /* Our device tree, NULL if none */Actually, the print is guarded with
CONFIG_NIOS2, so it is safe to use 32bits.Or shall we invent a "print pointer address"?
Simon, Tom, what's your take on this ?
Best regards,
Marek Vasut
PATCH v2 7/8 nios2: show fdt blob address in board info command
Hi,
Quoted 20 lines · Marek Vasut
Quoted 19 lines · Thomas Chou
Hi Marek,
Quoted 1 line
Quoted 1 line
Quoted 1 line
I think this will not work on 64bit machines.
I tried 64bits with
print_lnum("fdt_blob", (u64)gd->fdt_blob);But got this warning,
CC
common/cmd_bdinfo.ocommon/cmd_bdinfo.c: In function 'do_bdinfo':common/cmd_bdinfo.c:180:25: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]print_lnum("fdt_blob", (u64)gd->fdt_blob); ^
include/asm-generic/global_data.h
const void*fdt_blob; /* Our device tree, NULL if none */
Quoted 6 lines
Quoted 4 lines
Actually, the print is guarded with
CONFIG_NIOS2, so it is safe to use 32bits.Or shall we invent a "print pointer address"?
Simon, Tom, what's your take on this ?
From what I can tell this code is not generic, and is built for NIOS only. So IMO the patch is fine and we don't need to worry about 64-bit.
Regards,
Simon
PATCH v2 7/8 nios2: show fdt blob address in board info command
Quoted 31 lines · Simon Glass
Hi,
Quoted 28 lines · Marek Vasut
Quoted 27 lines · Thomas Chou
Hi Marek,
Quoted 1 line
Quoted 1 line
Quoted 1 line
I think this will not work on 64bit machines.
I tried 64bits with
print_lnum("fdt_blob", (u64)gd->fdt_blob);But got this warning,
CC
common/cmd_bdinfo.o
common/cmd_bdinfo.c: In function 'do_bdinfo':common/cmd_bdinfo.c:180:25: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]print_lnum("fdt_blob", (u64)gd->fdt_blob);^
include/asm-generic/global_data.hconst void
*fdt_blob; /* Our device tree, NULL if none */Actually, the print is guarded with
CONFIG_NIOS2, so it is safe to use 32bits.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Or shall we invent a "print pointer address"?
Simon, Tom, what's your take on this ?
From what I can tell this code is not generic, and is built for NIOS only. So IMO the patch is fine and we don't need to worry about 64-bit.
Oh my $DEITY, we have one bdinfo implementation per architecture, all in one ugly file. In that case, you're right, but this is truly horrible.
Best regards,
Marek Vasut
PATCH v2 7/8 nios2: show fdt blob address in board info command
In reply to Thomas ChouQuoted 6 lines · Thomas Chou
Show fdt blob address in board info command.
Signed-off-by Thomas Chou <[email protected]>--- common/cmd_bdinfo.c | 3 +++ 1 file changed, 3 insertions(+)
PATCH v2 7/8 nios2: show fdt blob address in board info command
In reply to Thomas ChouQuoted 6 lines · Thomas Chou
Show fdt blob address in board info command.
Signed-off-by Thomas Chou <[email protected]>--- common/cmd_bdinfo.c | 3 +++ 1 file changed, 3 insertions(+)
Applied to u-boot-nios2.
PATCH v2 8/8 nios2: enable device tree control of U-Boot
In reply to Thomas ChouThis patch adds device tree control of U-Boot to nios2 boards. The example dts is taken from Linux kernel.
--- arch/nios2/dts/.gitignore | 1 + arch/nios2/dts/3c120_devboard.dts | 153 +++++++++++++++++++++++++++++++++++++ arch/nios2/dts/Makefile | 11 +++ arch/nios2/dts/include/dt-bindings | 1 + configs/nios2-generic_defconfig | 2 + 5 files changed, 168 insertions(+) create mode 100644 arch/nios2/dts/.gitignore create mode 100644 arch/nios2/dts/3c120_devboard.dts create mode 100644 arch/nios2/dts/Makefile create mode 120000 arch/nios2/dts/include/dt-bindings
arch/nios2/dts/.gitignore new file +1 -0
@@ -0,0 +1 @@ +*.dtb
arch/nios2/dts/3c120_devboard.dts new file +153 -0
153 lines not on this page · raw message
arch/nios2/dts/Makefile new file +11 -0
@@ -0,0 +1,11 @@ +dtb-y += 3c120_devboard.dtb + +targets += $(dtb-y) + +DTC_FLAGS += -R 4 -p 0x1000 + +PHONY += dtbs +dtbs: $(addprefix $(obj)/, $(dtb-y)) + @: + +clean-files := *.dtb
arch/nios2/dts/include/dt-bindings new file +1 -0
@@ -0,0 +1 @@ +../../../../include/dt-bindings
configs/nios2-generic_defconfig +2 -0
@@ -1,5 +1,6 @@ CONFIG_NIOS2=y CONFIG_TARGET_NIOS2_GENERIC=y +CONFIG_DEFAULT_DEVICE_TREE="3c120_devboard" CONFIG_HUSH_PARSER=y # CONFIG_CMD_BOOTD is not set # CONFIG_CMD_IMLS is not set
@@ -10,4 +11,5 @@ CONFIG_HUSH_PARSER=y CONFIG_CMD_DHCP=y # CONFIG_CMD_NFS is not set CONFIG_CMD_PING=y +CONFIG_OF_CONTROL=y CONFIG_NET_RANDOM_ETHADDR=y
Signature · 1 line
2.1.4
PATCH v2 8/8 nios2: enable device tree control of U-Boot
Quoted 5 lines · Thomas Chou
This patch adds device tree control of U-Boot to nios2 boards. The example dts is taken from Linux kernel.
Signed-off-by Thomas Chou <[email protected]>Reviewed-by Simon Glass <[email protected]>
Quoted 12 lines
--- arch/nios2/dts/.gitignore | 1 + arch/nios2/dts/3c120_devboard.dts | 153 +++++++++++++++++++++++++++++++++++++ arch/nios2/dts/Makefile | 11 +++ arch/nios2/dts/include/dt-bindings | 1 + configs/nios2-generic_defconfig | 2 + 5 files changed, 168 insertions(+) create mode 100644 arch/nios2/dts/.gitignore create mode 100644 arch/nios2/dts/3c120_devboard.dts create mode 100644 arch/nios2/dts/Makefile create mode 120000 arch/nios2/dts/include/dt-bindings
You might also start working on dissolving the board/altera/nios2-generic/custom_fpga.h horror file, since with DT this is no longer needed :)
Best regards,
Marek Vasut
PATCH v2 8/8 nios2: enable device tree control of U-Boot
Hi Marek,
Quoted 3 lines · Marek Vasut
You might also start working on dissolving the
board/altera/nios2-generic/custom_fpga.hhorror file, since with DT this is no longer needed :)
Sure thing. This is on my TODO list.
May I know that if there is any work in process on Driver Model for Altera jtaguart, uart, spi and ethernet?
Best regards,
Thomas Chou
PATCH v2 8/8 nios2: enable device tree control of U-Boot
Quoted 1 line · Thomas Chou
Hi Marek,
Hi,
Quoted 9 lines · Marek Vasut
Quoted 3 lines
You might also start working on dissolving the
board/altera/nios2-generic/custom_fpga.hhorror file, since with DT this is no longer needed :)Sure thing. This is on my TODO list.
May I know that if there is any work in process on Driver Model for Altera jtaguart, uart, spi and ethernet?
There isn't any, feel free to start playing around :)
Best regards,
Marek Vasut
v2 cover nios2: add device tree control of U-Boot
In reply to Thomas ChouQuoted 5 lines · Thomas Chou
These patches add device tree control of U-Boot to nios2 boards.
v2
use SPDX license header.
use fdt relocation inboard_init_f.
Excellent, thanks :)
I can start picking the NIOS2 stuff into U-Boot as well if you want.
Best regards,
Marek Vasut
v2 cover nios2: add device tree control of U-Boot
Hi Marek,
Quoted 1 line · Marek Vasut
I can start picking the NIOS2 stuff into U-Boot as well if you want.
That's great! You are very kind and responsive. Thanks a lot. You can take over the custodianship of nios2 arch. Then I will be retired. :)
BTW, please also look over the earlier patches,
[PATCH] nios2: move command line configuration to Kconfig, Aug,28 [PATCH] nios2: enable CONFIG_NET_RANDOM_ETHADDR, Aug,29 And perhaps,
[PATCH] mmc_spi: fix big-endian support error on be_to_cpu16, Aug,31
Cheers,
Thomas Chou
v2 cover nios2: add device tree control of U-Boot
Quoted 1 line · Thomas Chou
Hi Marek,
Hi,
Quoted 7 lines · Marek Vasut
Quoted 1 line
I can start picking the NIOS2 stuff into U-Boot as well if you want.
That's great! You are very kind and responsive. Thanks a lot. You can take over the custodianship of nios2 arch. Then I will be retired. :)
BTW, please also look over the earlier patches,
Did you do the custodianing before ? Wow, looks like there's a bit of a chaos in this :)
I'll gladly leave it to you ;-)
Quoted 4 lines
[PATCH] nios2: move command line configuration to
Kconfig, Aug,28 [PATCH] nios2: enableCONFIG_NET_RANDOM_ETHADDR, Aug,29 And perhaps,
[PATCH]mmc_spi: fix big-endian support error onbe_to_cpu16, Aug,31
This one should be handled by Pantelis.
Best regards,
Marek Vasut
v2 cover nios2: add device tree control of U-Boot
In reply to Thomas ChouQuoted 7 lines · Thomas Chou
Hi Marek,
Quoted 1 line · Marek Vasut
I can start picking the NIOS2 stuff into U-Boot as well if you want.
That's great! You are very kind and responsive. Thanks a lot. You can take over the custodianship of nios2 arch. Then I will be retired. :)
Added Altera socfpga U-boot owner in CC list.
Quoted 10 lines
BTW, please also look over the earlier patches,
[PATCH] nios2: move command line configuration to
Kconfig, Aug,28 [PATCH] nios2: enableCONFIG_NET_RANDOM_ETHADDR, Aug,29 And perhaps,
[PATCH]mmc_spi: fix big-endian support error onbe_to_cpu16, Aug,31Cheers,
Thomas Chou
v4 cover nios2: add device tree control of U-Boot
In reply to Thomas ChouThese patches add device tree control of U-Boot to nios2 boards.
v2
use SPDX license header.
use fdt relocation in board_init_f.
v3
fix comment style.
v4
drop fdt_blob print in board info, which needs more discussion.
Thomas Chou (7):
nios2: permit device tree control of U-Boot
nios2: move altera_pio_init to board_early_init_r
nios2: BSS should be cleared only after board_init_f
nios2: enlarge the code relocation range
nios2: remove gp assignments in link script
nios2: define _end in link script
nios2: enable device tree control of U-Boot
arch/Kconfig | 1 + arch/nios2/cpu/start.S | 35 ++++--- arch/nios2/cpu/u-boot.lds | 14 ++- arch/nios2/dts/.gitignore | 1 + arch/nios2/dts/3c120_devboard.dts | 153 +++++++++++++++++++++++++++++ arch/nios2/dts/Makefile | 11 +++ arch/nios2/dts/include/dt-bindings | 1 + board/altera/nios2-generic/nios2-generic.c | 13 ++- configs/nios2-generic_defconfig | 2 + include/configs/nios2-generic.h | 1 + 10 files changed, 209 insertions(+), 23 deletions(-) create mode 100644 arch/nios2/dts/.gitignore create mode 100644 arch/nios2/dts/3c120_devboard.dts create mode 100644 arch/nios2/dts/Makefile create mode 120000 arch/nios2/dts/include/dt-bindings
Signature · 1 line
2.1.4
PATCH v4 1/7 nios2: permit device tree control of U-Boot
Enable this in the Kconfig so that nios2 boards can use device tree to configure U-Boot.
--- arch/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/Kconfig +1 -0
@@ -63,6 +63,7 @@ config NIOS2 bool "Nios II architecture" select HAVE_GENERIC_BOARD select SYS_GENERIC_BOARD + select SUPPORT_OF_CONTROL config OPENRISC bool "OpenRISC architecture"
Signature · 1 line
2.1.4
PATCH v4 1/7 nios2: permit device tree control of U-Boot
Quoted 9 lines · Thomas Chou
Enable this in the
Kconfigso that nios2 boards can use device tree to configure U-Boot.Signed-off-by Thomas Chou <[email protected]>Reviewed-by Simon Glass <[email protected]>Acked-by Marek Vasut <[email protected]>--- arch/Kconfig | 1 + 1 file changed, 1 insertion(+)
Applied to u-boot-nios.
PATCH v4 2/7 nios2: move altera_pio_init to board_early_init_r
In reply to Thomas ChouAs altera_pio_init() uses BSS, it should be moved to board_early_init_r().
--- board/altera/nios2-generic/nios2-generic.c | 13 +++++++++---- include/configs/nios2-generic.h | 1 + 2 files changed, 10 insertions(+), 4 deletions(-)
board/altera/nios2-generic/nios2-generic.c +9 -4
@@ -28,6 +28,15 @@ void early_flash_cmd_reset(void)int board_early_init_f (void ) { +#if defined(CONFIG_ENV_IS_IN_FLASH ) && defined(CONFIG_ENV_ADDR ) && \ + defined(CONFIG_CFI_FLASH_MTD ) +early_flash_cmd_reset (); +#endif +return 0 ; +} + +int board_early_init_r (void ) +{#ifdef CONFIG_ALTERA_PIO #ifdef LED_PIO_BASE altera_pio_init(LED_PIO_BASE, LED_PIO_WIDTH, 'o',
@@ -35,10 +44,6 @@ int board_early_init_f(void) "led");#endif #endif -#if defined(CONFIG_ENV_IS_IN_FLASH ) && defined(CONFIG_ENV_ADDR ) && \ - defined(CONFIG_CFI_FLASH_MTD ) -early_flash_cmd_reset (); -#endif return 0 ; }
include/configs/nios2-generic.h +1 -0
@@ -15,6 +15,7 @@#include "../board/altera/nios2-generic/custom_fpga.h" /* fpga parameters */ #define CONFIG_BOARD_NAME "nios2-generic"/* custom board name */ #define CONFIG_BOARD_EARLY_INIT_F /* enable early board-spec. init */ +#define CONFIG_BOARD_EARLY_INIT_R #define CONFIG_DISPLAY_CPUINFO #define CONFIG_DISPLAY_BOARDINFO #define CONFIG_SYS_NIOS_SYSID_BASE CONFIG_SYS_SYSID_BASE
Signature · 1 line
2.1.4
PATCH v4 2/7 nios2: move altera_pio_init to board_early_init_r
Quoted 9 lines · Thomas Chou
As
altera_pio_init()uses BSS, it should be moved toboard_early_init_r().Signed-off-by Thomas Chou <[email protected]>Acked-by Marek Vasut <[email protected]>--- board/altera/nios2-generic/nios2-generic.c | 13 +++++++++---- include/configs/nios2-generic.h | 1 + 2 files changed, 10 insertions(+), 4 deletions(-)
Applied to u-boot-nios.
PATCH v4 3/7 nios2: BSS should be cleared only after board_init_f
In reply to Thomas ChouAs dtb in u-boot-dtb.bin overlapped the BSS section, we should delay the clearing of BSS until dtb is relocated in board_init_f().
--- arch/nios2/cpu/start.S | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-)
arch/nios2/cpu/start.S +16 -14
@@ -82,20 +82,6 @@ _cur: movhi r5, %hi(_cur - _start) bne r5, r6, 2b 3: - /* ZERO BSS/SBSS -- bss and sbss are assumed to be adjacent - * and between __bss_start and __bss_end. - */ - movhi r5, %hi(__bss_start) - ori r5, r5, %lo(__bss_start) - movhi r6, %hi(__bss_end) - ori r6, r6, %lo(__bss_end) - beq r5, r6, 5f - -4: stwio r0, 0(r5) - addi r5, r5, 4 - bne r5, r6, 4b -5: - /* JUMP TO RELOC ADDR */ movhi r4, %hi(_reloc) ori r4, r4, %lo(_reloc)
@@ -167,6 +153,22 @@ _reloc: relocate_code: mov sp, r4 /* Set the new sp */ mov r4, r5 + + /* + * ZERO BSS/SBSS -- bss and sbss are assumed to be adjacent + * and between __bss_start and __bss_end. + */ + movhi r5, %hi(__bss_start) + ori r5, r5, %lo(__bss_start) + movhi r6, %hi(__bss_end) + ori r6, r6, %lo(__bss_end) + beq r5, r6, 5f + +4: stwio r0, 0(r5) + addi r5, r5, 4 + bne r5, r6, 4b +5: + movhi r8, %hi(board_init_r at h) ori r8, r8, %lo(board_init_r at h) callr r8
Signature · 1 line
2.1.4
PATCH v4 3/7 nios2: BSS should be cleared only after board_init_f
Quoted 9 lines · Thomas Chou
As dtb in u-boot-dtb.bin overlapped the BSS section, we should delay the clearing of BSS until dtb is relocated in
board_init_f().Signed-off-by Thomas Chou <[email protected]>Acked-by Marek Vasut <[email protected]>--- arch/nios2/cpu/start.S | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-)
Applied to u-boot-nios.
PATCH v4 4/7 nios2: enlarge the code relocation range
In reply to Thomas ChouAs we will use u-boot-dtb.bin, the code relocation range should be adjusted to accommodate the additional dtb. It might be overkilled to look into dtb header to find the dtb size, so we will simply use CONFIG_SYS_MONITOR_LEN.
--- arch/nios2/cpu/start.S | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/nios2/cpu/start.S +3 -2
@@ -73,8 +73,9 @@ _cur: movhi r5, %hi(_cur - _start) ori r5, r5, %lo(_start) /* r5 <- linked _start */ beq r4, r5, 3f - movhi r6, %hi(_edata) - ori r6, r6, %lo(_edata) + movhi r6, %hi(CONFIG_SYS_MONITOR_LEN) + ori r6, r6, %lo(CONFIG_SYS_MONITOR_LEN) + add r6, r6, r5 2: ldwio r7, 0(r4) addi r4, r4, 4 stwio r7, 0(r5)
Signature · 1 line
2.1.4
PATCH v4 4/7 nios2: enlarge the code relocation range
Quoted 10 lines · Thomas Chou
As we will use u-boot-dtb.bin, the code relocation range should be adjusted to accommodate the additional dtb. It might be overkilled to look into dtb header to find the dtb size, so we will simply use
CONFIG_SYS_MONITOR_LEN.Signed-off-by Thomas Chou <[email protected]>--- arch/nios2/cpu/start.S | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Applied to u-boot-nios.
PATCH v4 5/7 nios2: remove gp assignments in link script
In reply to Thomas ChouSince we don't use gp for small data with option "-G0", we use gp as global data pointer. The _gp location is not needed.
The ALIGN(16) was for gp only. It is removed, so that we can get correct address of dtb in u-boot-dtb.bin image.
--- arch/nios2/cpu/u-boot.lds | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
arch/nios2/cpu/u-boot.lds +5 -3
@@ -50,9 +50,11 @@ SECTIONS *(.gnu.linkonce.d*) } - . = ALIGN(16); - _gp = .; /* Global pointer addr */ - PROVIDE (gp = .); + /* + * gp - Since we don't use gp for small data with option "-G0", + * we will use gp as global data pointer. The _gp location is + * not needed. + */ .sdata : {
Signature · 1 line
2.1.4
PATCH v4 5/7 nios2: remove gp assignments in link script
Quoted 7 lines · Thomas Chou
Since we don't use gp for small data with option "-G0", we use gp as global data pointer. The
_gplocation is not needed.The ALIGN(16) was for gp only. It is removed, so that we can get correct address of dtb in u-boot-dtb.bin image.
Quoted 7 lines
Signed-off-by Thomas Chou <[email protected]>Reviewed-by Simon Glass <[email protected]>Acked-by Marek Vasut <[email protected]>--- arch/nios2/cpu/u-boot.lds | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
Applied to u-boot-nios.
PATCH v4 6/7 nios2: define _end in link script
In reply to Thomas ChouSince commit 44c6e6591cb451ae606f8bde71dd5fb7b4002544 "rename _end to __bss_end__" , the _end was removed. But we need it now for separated device tree control, ie, CONFIG_OF_SEPARATE .
The _end is used by fdtdec_setup() to find the blob.
--- arch/nios2/cpu/u-boot.lds | 6 ++++++ 1 file changed, 6 insertions(+)
arch/nios2/cpu/u-boot.lds +6 -0
@@ -67,6 +67,12 @@ SECTIONS _edata = .; PROVIDE (edata = .); + /* + * _end - This is end of u-boot.bin image. + * dtb will be appended here to make u-boot-dtb.bin + */ + _end = .; + /* UNINIT DATA - Small uninitialized data is first so it's * adjacent to sdata and can be referenced via gp. The normal * bss follows. We keep it adjacent to simplify init code.
Signature · 1 line
2.1.4
PATCH v4 6/7 nios2: define _end in link script
Quoted 5 lines · Thomas Chou
Since commit
44c6e6591cb451ae606f8bde71dd5fb7b4002544"rename_endto__bss_end__" , the_endwas removed. But we need it now for separated device tree control, ie,CONFIG_OF_SEPARATE.
Quoted 9 lines
The
_endis used byfdtdec_setup()to find the blob.Signed-off-by Thomas Chou <[email protected]>Acked-by Marek Vasut <[email protected]>Reviewed-by Simon Glass <[email protected]>--- arch/nios2/cpu/u-boot.lds | 6 ++++++ 1 file changed, 6 insertions(+)
Applied to u-boot-nios.
PATCH v4 7/7 nios2: enable device tree control of U-Boot
In reply to Thomas ChouThis patch adds device tree control of U-Boot to nios2 boards. The example dts is taken from Linux kernel.
--- arch/nios2/dts/.gitignore | 1 + arch/nios2/dts/3c120_devboard.dts | 153 +++++++++++++++++++++++++++++++++++++ arch/nios2/dts/Makefile | 11 +++ arch/nios2/dts/include/dt-bindings | 1 + configs/nios2-generic_defconfig | 2 + 5 files changed, 168 insertions(+) create mode 100644 arch/nios2/dts/.gitignore create mode 100644 arch/nios2/dts/3c120_devboard.dts create mode 100644 arch/nios2/dts/Makefile create mode 120000 arch/nios2/dts/include/dt-bindings
arch/nios2/dts/.gitignore new file +1 -0
@@ -0,0 +1 @@ +*.dtb
arch/nios2/dts/3c120_devboard.dts new file +153 -0
153 lines not on this page · raw message
arch/nios2/dts/Makefile new file +11 -0
@@ -0,0 +1,11 @@ +dtb-y += 3c120_devboard.dtb + +targets += $(dtb-y) + +DTC_FLAGS += -R 4 -p 0x1000 + +PHONY += dtbs +dtbs: $(addprefix $(obj)/, $(dtb-y)) + @: + +clean-files := *.dtb
arch/nios2/dts/include/dt-bindings new file +1 -0
@@ -0,0 +1 @@ +../../../../include/dt-bindings
configs/nios2-generic_defconfig +2 -0
@@ -1,5 +1,6 @@ CONFIG_NIOS2=y CONFIG_TARGET_NIOS2_GENERIC=y +CONFIG_DEFAULT_DEVICE_TREE="3c120_devboard" CONFIG_HUSH_PARSER=y # CONFIG_CMD_BOOTD is not set # CONFIG_CMD_IMLS is not set
@@ -10,4 +11,5 @@ CONFIG_HUSH_PARSER=y CONFIG_CMD_DHCP=y # CONFIG_CMD_NFS is not set CONFIG_CMD_PING=y +CONFIG_OF_CONTROL=y CONFIG_NET_RANDOM_ETHADDR=y
Signature · 1 line
2.1.4
PATCH v4 7/7 nios2: enable device tree control of U-Boot
Quoted 13 lines · Thomas Chou
This patch adds device tree control of U-Boot to nios2 boards. The example dts is taken from Linux kernel.
Signed-off-by Thomas Chou <[email protected]>Reviewed-by Simon Glass <[email protected]>Acked-by Marek Vasut <[email protected]>--- arch/nios2/dts/.gitignore | 1 + arch/nios2/dts/3c120_devboard.dts | 153 +++++++++++++++++++++++++++++++++++++ arch/nios2/dts/Makefile | 11 +++ arch/nios2/dts/include/dt-bindings | 1 + configs/nios2-generic_defconfig | 2 + 5 files changed, 168 insertions(+)
Quoted 5 lines
create mode 100644
arch/nios2/dts/.gitignorecreate mode 100644arch/nios2/dts/3c120_devboard.dtscreate mode 100644arch/nios2/dts/Makefilecreate mode 120000arch/nios2/dts/include/dt-bindings
Applied to u-boot-nios.
v4 cover nios2: add device tree control of U-Boot
In reply to Thomas ChouQuoted 10 lines · Thomas Chou
These patches add device tree control of U-Boot to nios2 boards.
v2
use SPDX license header.
use fdt relocation inboard_init_f.
v3
fix comment style.
v4
dropfdt_blobprint in board info, which needs more discussion.
Quoted 8 lines
Thomas Chou (7):
nios2: permit device tree control of U-Boot
nios2: movealtera_pio_inittoboard_early_init_r
nios2: BSS should be cleared only afterboard_init_f
nios2: enlarge the code relocation range
nios2: remove gp assignments in link script
nios2: define_endin link script
nios2: enable device tree control of U-Boot
Hi,
Nice, I like seeing how NIOS2 getting back to shape. btw you could have waited a few days before applying patches that were just posted.
Best regards,
Marek Vasut
v4 cover nios2: add device tree control of U-Boot
Hi Marek,
Quoted 2 lines · Marek Vasut
Nice, I like seeing how NIOS2 getting back to shape. btw you could have waited a few days before applying patches that were just posted.
Thanks for reminding. I used to wait a week. But I hate too many things floating around, that would prevent me to focus. Something we might have enough discussion or too trivial..
Thank you again. And please continue your great work.
Cheers,
Thomas Chou