RISC-V S-mode support
v5 cover RISC-V S-mode support
This patchset allows us runing u-boot in S-mode which is useful on platforms where M-mode runtime firmware is an independent firmware and u-boot is used as last stage OS bootloader.
The patchset based upon git://git.denx.de/u-boot-riscv.git
and is tested on QEMU in both M-mode and S-mode.
For S-mode testing, we have used u-boot.bin as payload of latest BBL (at commit 6ebd0f2a46255d0c76dad3c05b16c1d154795d26) applied with following changes:
machine/emulation.c +6 -0
@@ -162,6 +162,12 @@ static inline int emulate_read_csr(int num, uintptr_t mstatus, uintptr_t* resultswitch (num) { +case CSR_MISA : + *result =read_csr (misa); +return 0 ; +case CSR_MHARTID : + *result =read_csr (mhartid); +return 0 ;case CSR_CYCLE :if (!((counteren >> (CSR_CYCLE -CSR_CYCLE )) &1 ))return -1 ;
Changes since v4:
- Rebased series based on commit 52923c6db7f00e0197ec894c8c1bb8a7681974bb of git://git.denx.de/u-boot-riscv.git
- Added a patch to remove redundant a2 store on DRAM base. This store was creating problem booting U-Boot in S-mode using BBL.
Changes since v3:
- Replaced 'u-boot' with 'U-Boot' in commit message
- Dropped 'an' in RISCV_SMODE kconfig option help message
- Added appropriate #ifdef in arch/riscv/lib/interrupts.c
Changes since v2:
- Dropped 'default n" from RISCV_SMODE kconfig option
- Replaced '-smode_' in defconfig names with '_smode_'
Changes since v1:
- Rebased upon latest git://git.denx.de/u-boot-riscv.git
- Add details in cover letter for running u-boot in S-mode using BBL
Anup Patel (4):
riscv: Add kconfig option to run U-Boot in S-mode
riscv: qemu: Use different SYS_TEXT_BASE for S-mode
riscv: Add S-mode defconfigs for QEMU virt machine
riscv: Remove redundant a2 store on DRAM base in start.S
arch/riscv/Kconfig | 5 ++++ arch/riscv/cpu/start.S | 35 +++++++++++++++++++++++-- arch/riscv/include/asm/encoding.h | 2 ++ arch/riscv/lib/interrupts.c | 36 +++++++++++++++++++------- board/emulation/qemu-riscv/Kconfig | 3 ++- board/emulation/qemu-riscv/MAINTAINERS | 2 ++ configs/qemu-riscv32_smode_defconfig | 10 +++++++ configs/qemu-riscv64_smode_defconfig | 11 ++++++++ 8 files changed, 92 insertions(+), 12 deletions(-) create mode 100644 configs/qemu-riscv32_smode_defconfig create mode 100644 configs/qemu-riscv64_smode_defconfig
Signature · 1 line
2.17.1
PATCH v5 1/4 riscv: Add kconfig option to run U-Boot in S-mode
This patch adds kconfig option RISCV_SMODE to run U-Boot in S-mode. When this opition is enabled we use s<xyz> CSRs instead of m<xyz> CSRs.
It is important to note that there is no equivalent S-mode CSR for misa and mhartid CSRs so we expect M-mode runtime firmware (BBL or equivalent) to emulate misa and mhartid CSR read.
In-future, we will have more patches to avoid accessing misa and mhartid CSRs from S-mode.
--- arch/riscv/Kconfig | 5 +++++ arch/riscv/cpu/start.S | 33 ++++++++++++++++++++++++++++ arch/riscv/include/asm/encoding.h | 2 ++ arch/riscv/lib/interrupts.c | 36 +++++++++++++++++++++++-------- 4 files changed, 67 insertions(+), 9 deletions(-)
arch/riscv/Kconfig +5 -0
@@ -55,6 +55,11 @@ config RISCV_ISA_C config RISCV_ISA_A def_bool y +config RISCV_SMODE + bool "Run in S-Mode" + help + Enable this option to build U-Boot for RISC-V S-Mode + config 32BIT bool
arch/riscv/cpu/start.S +33 -0
@@ -41,10 +41,18 @@ _start: li t0, CONFIG_SYS_SDRAM_BASE SREG a2, 0(t0) la t0, trap_entry +#ifdef CONFIG_RISCV_SMODE + csrw stvec, t0 +#else csrw mtvec, t0 +#endif /* mask all interrupts */ +#ifdef CONFIG_RISCV_SMODE + csrw sie, zero +#else csrw mie, zero +#endif /* Enable cache */ jal icache_enable
@@ -166,7 +174,11 @@ fix_rela_dyn: */ la t0, trap_entry add t0, t0, t6 +#ifdef CONFIG_RISCV_SMODE + csrw stvec, t0 +#else csrw mtvec, t0 +#endif clear_bss: la t0, __bss_start /* t0 <- rel __bss_start in FLASH */
@@ -238,17 +250,34 @@ trap_entry: SREG x29, 29*REGBYTES(sp) SREG x30, 30*REGBYTES(sp) SREG x31, 31*REGBYTES(sp) +#ifdef CONFIG_RISCV_SMODE + csrr a0, scause + csrr a1, sepc +#else csrr a0, mcause csrr a1, mepc +#endif mv a2, sp jal handle_trap +#ifdef CONFIG_RISCV_SMODE + csrw sepc, a0 +#else csrw mepc, a0 +#endif +#ifdef CONFIG_RISCV_SMODE +/* + * Remain in S-mode after sret + */ + li t0, SSTATUS_SPP + csrs sstatus, t0 +#else /* * Remain in M-mode after mret */ li t0, MSTATUS_MPP csrs mstatus, t0 +#endif LREG x1, 1*REGBYTES(sp) LREG x2, 2*REGBYTES(sp) LREG x3, 3*REGBYTES(sp)
@@ -281,4 +310,8 @@ trap_entry: LREG x30, 30*REGBYTES(sp) LREG x31, 31*REGBYTES(sp) addi sp, sp, 32*REGBYTES +#ifdef CONFIG_RISCV_SMODE + sret +#else mret +#endif
arch/riscv/include/asm/encoding.h +2 -0
@@ -143,6 +143,8 @@# define MCAUSE_CAUSE MCAUSE32_CAUSE#endif +#define SCAUSE_INT MCAUSE_INT +#define RISCV_PGSHIFT 12#define RISCV_PGSIZE BIT(RISCV_PGSHIFT)
arch/riscv/lib/interrupts.c +27 -9
@@ -34,17 +34,35 @@ int disable_interrupts(void)return 0 ; } -ulong handle_trap (ulong mcause,ulong epc,struct pt_regs *regs) +ulong handle_trap (ulong cause,ulong epc,struct pt_regs *regs) { -ulong is_int; +ulong is_irq, irq; - is_int = (mcause &MCAUSE_INT ); -if ((is_int) && ((mcause &MCAUSE_CAUSE ) ==IRQ_M_EXT )) -external_interrupt (0 );/* handle_m_ext_interrupt */ -else if ((is_int) && ((mcause &MCAUSE_CAUSE ) ==IRQ_M_TIMER )) -timer_interrupt (0 );/* handle_m_timer_interrupt */ -else -_exit_trap (mcause, epc, regs); +#ifdef CONFIG_RISCV_SMODE + is_irq = (cause &SCAUSE_INT ); + irq = (cause & ~SCAUSE_INT ); +#else + is_irq = (cause &MCAUSE_INT ); + irq = (cause & ~MCAUSE_INT ); +#endif + +if (is_irq) { +switch (irq) { +case IRQ_M_EXT : +case IRQ_S_EXT : +external_interrupt (0 );/* handle external interrupt */ +break ; +case IRQ_M_TIMER : +case IRQ_S_TIMER : +timer_interrupt (0 );/* handle timer interrupt */ +break ; +default : +_exit_trap (cause, epc, regs); +break ; + }; + }else { +_exit_trap (cause, epc, regs); + }return epc; }
Signature · 1 line
2.17.1
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v5 1/4 riscv: Add kconfig option to run U-Boot in S-mode
Quoted 93 lines
Quoted 93 lines
Subject: [PATCH v5 1/4] riscv: Add kconfig option to run U-Boot in S-mode
This patch adds kconfig option
RISCV_SMODEto run U-Boot in S-mode. When this opition is enabled we use s<xyz> CSRs instead of m<xyz> CSRs.It is important to note that there is no equivalent S-mode CSR for misa and mhartid CSRs so we expect M-mode runtime firmware (BBL or equivalent) to emulate misa and mhartid CSR read.
In-future, we will have more patches to avoid accessing misa and mhartid CSRs from S-mode.
Signed-off-by Anup Patel <[email protected]>Reviewed-by Bin Meng <[email protected]>Tested-by Bin Meng <[email protected]>Reviewed-by Lukas Auer <[email protected]>--- arch/riscv/Kconfig | 5 +++++ arch/riscv/cpu/start.S | 33 ++++++++++++++++++++++++++++ arch/riscv/include/asm/encoding.h | 2 ++ arch/riscv/lib/interrupts.c | 36 +++++++++++++++++++++++-------- 4 files changed, 67 insertions(+), 9 deletions(-)arch/riscv/Kconfig index 3e0af55e71..732a357a99 renamed from arch/riscv/Kconfig +0
-0100644
arch/riscv/Kconfig +5
-0@@ -55,6 +55,11 @@ config RISCV_ISA_C config RISCV_ISA_A def_bool y +config RISCV_SMODE + bool "Run in S-Mode" + help + Enable this option to build U-Boot for RISC-V S-Mode + config 32BIT boolarch/riscv/cpu/start.S index renamed from arch/riscv/cpu/start.S +0
-0
15e1b8199a..704190f946100644arch/riscv/cpu/start.S +21
-0@@ -41,10 +41,18 @@ _start: li t0, CONFIG_SYS_SDRAM_BASE SREG a2, 0(t0) la t0, trap_entry +#ifdef CONFIG_RISCV_SMODE + csrw stvec, t0 +#else csrw mtvec, t0 +#endif /* mask all interrupts */ +#ifdef CONFIG_RISCV_SMODE + csrw sie, zero +#else csrw mie, zero +#endif /* Enable cache */ jal icache_enable@@ -166,7 +174,11 @@ fix_rela_dyn: */ la t0, trap_entry add t0, t0, t6 +#ifdef CONFIG_RISCV_SMODE + csrw stvec, t0 +#else csrw mtvec, t0 +#endif clear_bss: la t0, __bss_start /* t0 <- rel __bss_start in FLASH */@@ -238,17 +250,34 @@ trap_entry: SREG x29, 29*REGBYTES(sp) SREG x30, 30*REGBYTES(sp) SREG x31, 31*REGBYTES(sp) +#ifdef CONFIG_RISCV_SMODE + csrr a0, scause + csrr a1, sepc +#else csrr a0, mcause csrr a1, mepc +#endif mv a2, sp jal handle_trap +#ifdef CONFIG_RISCV_SMODE + csrw sepc, a0 +#else csrw mepc, a0 +#endif
Quoted 13 lines
arch/riscv/cpu/start.S trap_entry: · line 280
Quoted 13 lines
arch/riscv/cpu/start.S +8
-0+#ifdef CONFIG_RISCV_SMODE +/* + * Remain in S-mode after sret + */ + li t0, SSTATUS_SPP + csrs sstatus, t0 +#else /* * Remain in M-mode after mret */ li t0, MSTATUS_MPP csrs mstatus, t0 +#endif
It only the difference between s and m in csr. The code seem to be duplicate too much. Can you implement it in macro ?
or consider to separate it in different .S file
It may too complex to maintain in the future.
B.R
Rick
Quoted 78 lines
Quoted 77 lines
arch/riscv/cpu/start.S +4
-0LREG x1, 1*REGBYTES(sp) LREG x2, 2*REGBYTES(sp) LREG x3, 3*REGBYTES(sp)@@ -281,4 +310,8 @@ trap_entry: LREG x30, 30*REGBYTES(sp) LREG x31, 31*REGBYTES(sp) addi sp, sp, 32*REGBYTES +#ifdef CONFIG_RISCV_SMODE + sret +#else mret +#endifarch/riscv/include/asm/encoding.h +2
-0@@ -143,6 +143,8 @@# define MCAUSE_CAUSE MCAUSE32_CAUSE#endif +#define SCAUSE_INT MCAUSE_INT +#define RISCV_PGSHIFT 12#define RISCV_PGSIZE BIT(RISCV_PGSHIFT)arch/riscv/lib/interrupts.c index renamed from arch/riscv/lib/interrupts.c +0
-0
903a1c4cd5..8793f233d0100644arch/riscv/lib/interrupts.c +27
-10@@ -34,17 +34,35 @@ int disable_interrupts(void)return 0 ; } -ulong handle_trap (ulong mcause,ulong epc,struct pt_regs *regs) +ulong handle_trap (ulong cause,ulong epc,struct pt_regs *regs) { -ulong is_int; +ulong is_irq, irq; - is_int = (mcause &MCAUSE_INT ); -if ((is_int) && ((mcause &MCAUSE_CAUSE ) ==IRQ_M_EXT )) -external_interrupt (0 );/* handle_m_ext_interrupt */ -else if ((is_int) && ((mcause &MCAUSE_CAUSE ) ==IRQ_M_TIMER )) -timer_interrupt (0 );/* handle_m_timer_interrupt */ -else -_exit_trap (mcause, epc, regs); +#ifdef CONFIG_RISCV_SMODE + is_irq = (cause &SCAUSE_INT ); + irq = (cause & ~SCAUSE_INT ); +#else + is_irq = (cause &MCAUSE_INT ); + irq = (cause & ~MCAUSE_INT ); +#endif + +if (is_irq) { +switch (irq) { +case IRQ_M_EXT : +case IRQ_S_EXT : +external_interrupt (0 );/* handle external interrupt */ +break ; +case IRQ_M_TIMER : +case IRQ_S_TIMER : +timer_interrupt (0 );/* handle timer interrupt */ +break ; +default : +_exit_trap (cause, epc, regs); +break ; + }; + }else { +_exit_trap (cause, epc, regs); + }return epc; } --2.17.1
PATCH v5 1/4 riscv: Add kconfig option to run U-Boot in S-mode
Quoted 113 lines · Rick Chen
Quoted 94 lines
Quoted 94 lines
Subject: [PATCH v5 1/4] riscv: Add kconfig option to run U-Boot in S-mode
This patch adds kconfig option
RISCV_SMODEto run U-Boot in S-mode. When this opition is enabled we use s<xyz> CSRs instead of m<xyz> CSRs.It is important to note that there is no equivalent S-mode CSR for misa and mhartid CSRs so we expect M-mode runtime firmware (BBL or equivalent) to emulate misa and mhartid CSR read.
In-future, we will have more patches to avoid accessing misa and mhartid CSRs from S-mode.
Signed-off-by Anup Patel <[email protected]>Reviewed-by Bin Meng <[email protected]>Tested-by Bin Meng <[email protected]>Reviewed-by Lukas Auer <[email protected]>--- arch/riscv/Kconfig | 5 +++++ arch/riscv/cpu/start.S | 33 ++++++++++++++++++++++++++++ arch/riscv/include/asm/encoding.h | 2 ++ arch/riscv/lib/interrupts.c | 36 +++++++++++++++++++++++-------- 4 files changed, 67 insertions(+), 9 deletions(-)arch/riscv/Kconfig index 3e0af55e71..732a357a99 renamed from arch/riscv/Kconfig +0
-0100644
arch/riscv/Kconfig +5
-0@@ -55,6 +55,11 @@ config RISCV_ISA_C config RISCV_ISA_A def_bool y +config RISCV_SMODE + bool "Run in S-Mode" + help + Enable this option to build U-Boot for RISC-V S-Mode + config 32BIT boolarch/riscv/cpu/start.S index renamed from arch/riscv/cpu/start.S +0
-0
15e1b8199a..704190f946100644arch/riscv/cpu/start.S +21
-0@@ -41,10 +41,18 @@ _start: li t0, CONFIG_SYS_SDRAM_BASE SREG a2, 0(t0) la t0, trap_entry +#ifdef CONFIG_RISCV_SMODE + csrw stvec, t0 +#else csrw mtvec, t0 +#endif /* mask all interrupts */ +#ifdef CONFIG_RISCV_SMODE + csrw sie, zero +#else csrw mie, zero +#endif /* Enable cache */ jal icache_enable@@ -166,7 +174,11 @@ fix_rela_dyn: */ la t0, trap_entry add t0, t0, t6 +#ifdef CONFIG_RISCV_SMODE + csrw stvec, t0 +#else csrw mtvec, t0 +#endif clear_bss: la t0, __bss_start /* t0 <- rel __bss_start in FLASH */@@ -238,17 +250,34 @@ trap_entry: SREG x29, 29*REGBYTES(sp) SREG x30, 30*REGBYTES(sp) SREG x31, 31*REGBYTES(sp) +#ifdef CONFIG_RISCV_SMODE + csrr a0, scause + csrr a1, sepc +#else csrr a0, mcause csrr a1, mepc +#endif mv a2, sp jal handle_trap +#ifdef CONFIG_RISCV_SMODE + csrw sepc, a0 +#else csrw mepc, a0 +#endifQuoted 13 lines
arch/riscv/cpu/start.S trap_entry: · line 280
Quoted 13 lines
arch/riscv/cpu/start.S +8
-0+#ifdef CONFIG_RISCV_SMODE +/* + * Remain in S-mode after sret + */ + li t0, SSTATUS_SPP + csrs sstatus, t0 +#else /* * Remain in M-mode after mret */ li t0, MSTATUS_MPP csrs mstatus, t0 +#endifIt only the difference between s and m in csr. The code seem to be duplicate too much. Can you implement it in macro ?
or consider to separate it in different .S file
Quoted 2 lines
It may too complex to maintain in the future.
Here are few reasons why not to do this:
1. We don't have same set of CSRs for M-mode and S-mode. For certain, M-mode CSRs we don't have any corresponding S-mode CSRs.
2. Number of CSRs for each mode are really few so there won't be much #ifdef in code. Having separate .S will be total overkill and too much code duplication.
3. Using macro would mean we use incomplete CSR names
examples: "status" for "mstatus"/"sstatus", "epc" for "mepc"/"sepc", etc. This means we cannot grep code for use of a CSR. I think this is less readable compared to using #ifdef
Despite above reasons, above can always be attempted as separate patch.
Regards,
Anup
PATCH v5 1/4 riscv: Add kconfig option to run U-Boot in S-mode
Quoted 129 lines · Anup Patel
Quoted 113 lines · Rick Chen
Quoted 94 lines
Quoted 94 lines
Subject: [PATCH v5 1/4] riscv: Add kconfig option to run U-Boot in S-mode
This patch adds kconfig option
RISCV_SMODEto run U-Boot in S-mode. When this opition is enabled we use s<xyz> CSRs instead of m<xyz> CSRs.It is important to note that there is no equivalent S-mode CSR for misa and mhartid CSRs so we expect M-mode runtime firmware (BBL or equivalent) to emulate misa and mhartid CSR read.
In-future, we will have more patches to avoid accessing misa and mhartid CSRs from S-mode.
Signed-off-by Anup Patel <[email protected]>Reviewed-by Bin Meng <[email protected]>Tested-by Bin Meng <[email protected]>Reviewed-by Lukas Auer <[email protected]>--- arch/riscv/Kconfig | 5 +++++ arch/riscv/cpu/start.S | 33 ++++++++++++++++++++++++++++ arch/riscv/include/asm/encoding.h | 2 ++ arch/riscv/lib/interrupts.c | 36 +++++++++++++++++++++++-------- 4 files changed, 67 insertions(+), 9 deletions(-)arch/riscv/Kconfig index 3e0af55e71..732a357a99 renamed from arch/riscv/Kconfig +0
-0100644
arch/riscv/Kconfig +5
-0@@ -55,6 +55,11 @@ config RISCV_ISA_C config RISCV_ISA_A def_bool y +config RISCV_SMODE + bool "Run in S-Mode" + help + Enable this option to build U-Boot for RISC-V S-Mode + config 32BIT boolarch/riscv/cpu/start.S index renamed from arch/riscv/cpu/start.S +0
-0
15e1b8199a..704190f946100644arch/riscv/cpu/start.S +21
-0@@ -41,10 +41,18 @@ _start: li t0, CONFIG_SYS_SDRAM_BASE SREG a2, 0(t0) la t0, trap_entry +#ifdef CONFIG_RISCV_SMODE + csrw stvec, t0 +#else csrw mtvec, t0 +#endif /* mask all interrupts */ +#ifdef CONFIG_RISCV_SMODE + csrw sie, zero +#else csrw mie, zero +#endif /* Enable cache */ jal icache_enable@@ -166,7 +174,11 @@ fix_rela_dyn: */ la t0, trap_entry add t0, t0, t6 +#ifdef CONFIG_RISCV_SMODE + csrw stvec, t0 +#else csrw mtvec, t0 +#endif clear_bss: la t0, __bss_start /* t0 <- rel __bss_start in FLASH */@@ -238,17 +250,34 @@ trap_entry: SREG x29, 29*REGBYTES(sp) SREG x30, 30*REGBYTES(sp) SREG x31, 31*REGBYTES(sp) +#ifdef CONFIG_RISCV_SMODE + csrr a0, scause + csrr a1, sepc +#else csrr a0, mcause csrr a1, mepc +#endif mv a2, sp jal handle_trap +#ifdef CONFIG_RISCV_SMODE + csrw sepc, a0 +#else csrw mepc, a0 +#endifQuoted 13 lines
arch/riscv/cpu/start.S trap_entry: · line 280
Quoted 13 lines
arch/riscv/cpu/start.S +8
-0+#ifdef CONFIG_RISCV_SMODE +/* + * Remain in S-mode after sret + */ + li t0, SSTATUS_SPP + csrs sstatus, t0 +#else /* * Remain in M-mode after mret */ li t0, MSTATUS_MPP csrs mstatus, t0 +#endifIt only the difference between s and m in csr. The code seem to be duplicate too much. Can you implement it in macro ?
or consider to separate it in different .S fileQuoted 2 lines
It may too complex to maintain in the future.
Here are few reasons why not to do this:
1. We don't have same set of CSRs for M-mode and S-mode. For certain, M-mode CSRs we don't have any corresponding S-mode CSRs.
2. Number of CSRs for each mode are really few so there won't be much #ifdef in code. Having separate .S will be total overkill and too much code duplication.
3. Using macro would mean we use incomplete CSR names
examples: "status" for "mstatus"/"sstatus", "epc" for "mepc"/"sepc", etc. This means we cannot grep code for use of a CSR. I think this is less readable compared to using #ifdef
Quoted 2 lines
Despite above reasons, above can always be attempted as separate patch.
On AArch64, we determine the current EL during runtime and then branch to respective labels for different ELs (see the switch_el macro for asm as well as current_el() for C).
Wouldn't it make sense to attempt something similar with S-mode, so that the same binary can run either in M or in S depending on how it was started?
Alex
PATCH v5 1/4 riscv: Add kconfig option to run U-Boot in S-mode
Quoted 136 lines · Alexander Graf
Quoted 129 lines · Anup Patel
Quoted 113 lines · Rick Chen
Quoted 94 lines
Quoted 94 lines
Subject: [PATCH v5 1/4] riscv: Add kconfig option to run U-Boot in S-mode
This patch adds kconfig option
RISCV_SMODEto run U-Boot in S-mode. When this opition is enabled we use s<xyz> CSRs instead of m<xyz> CSRs.It is important to note that there is no equivalent S-mode CSR for misa and mhartid CSRs so we expect M-mode runtime firmware (BBL or equivalent) to emulate misa and mhartid CSR read.
In-future, we will have more patches to avoid accessing misa and mhartid CSRs from S-mode.
Signed-off-by Anup Patel <[email protected]>Reviewed-by Bin Meng <[email protected]>Tested-by Bin Meng <[email protected]>Reviewed-by Lukas Auer <[email protected]>--- arch/riscv/Kconfig | 5 +++++ arch/riscv/cpu/start.S | 33 ++++++++++++++++++++++++++++ arch/riscv/include/asm/encoding.h | 2 ++ arch/riscv/lib/interrupts.c | 36 +++++++++++++++++++++++-------- 4 files changed, 67 insertions(+), 9 deletions(-)arch/riscv/Kconfig index 3e0af55e71..732a357a99 renamed from arch/riscv/Kconfig +0
-0100644
arch/riscv/Kconfig +5
-0@@ -55,6 +55,11 @@ config RISCV_ISA_C config RISCV_ISA_A def_bool y +config RISCV_SMODE + bool "Run in S-Mode" + help + Enable this option to build U-Boot for RISC-V S-Mode + config 32BIT boolarch/riscv/cpu/start.S index renamed from arch/riscv/cpu/start.S +0
-0
15e1b8199a..704190f946100644arch/riscv/cpu/start.S +21
-0@@ -41,10 +41,18 @@ _start: li t0, CONFIG_SYS_SDRAM_BASE SREG a2, 0(t0) la t0, trap_entry +#ifdef CONFIG_RISCV_SMODE + csrw stvec, t0 +#else csrw mtvec, t0 +#endif /* mask all interrupts */ +#ifdef CONFIG_RISCV_SMODE + csrw sie, zero +#else csrw mie, zero +#endif /* Enable cache */ jal icache_enable@@ -166,7 +174,11 @@ fix_rela_dyn: */ la t0, trap_entry add t0, t0, t6 +#ifdef CONFIG_RISCV_SMODE + csrw stvec, t0 +#else csrw mtvec, t0 +#endif clear_bss: la t0, __bss_start /* t0 <- rel __bss_start in FLASH */@@ -238,17 +250,34 @@ trap_entry: SREG x29, 29*REGBYTES(sp) SREG x30, 30*REGBYTES(sp) SREG x31, 31*REGBYTES(sp) +#ifdef CONFIG_RISCV_SMODE + csrr a0, scause + csrr a1, sepc +#else csrr a0, mcause csrr a1, mepc +#endif mv a2, sp jal handle_trap +#ifdef CONFIG_RISCV_SMODE + csrw sepc, a0 +#else csrw mepc, a0 +#endifQuoted 13 lines
arch/riscv/cpu/start.S trap_entry: · line 280
Quoted 13 lines
arch/riscv/cpu/start.S +8
-0+#ifdef CONFIG_RISCV_SMODE +/* + * Remain in S-mode after sret + */ + li t0, SSTATUS_SPP + csrs sstatus, t0 +#else /* * Remain in M-mode after mret */ li t0, MSTATUS_MPP csrs mstatus, t0 +#endifIt only the difference between s and m in csr. The code seem to be duplicate too much. Can you implement it in macro ?
or consider to separate it in different .S fileQuoted 2 lines
It may too complex to maintain in the future.
Here are few reasons why not to do this:
1. We don't have same set of CSRs for M-mode and S-mode. For certain, M-mode CSRs we don't have any corresponding S-mode CSRs.
2. Number of CSRs for each mode are really few so there won't be much #ifdef in code. Having separate .S will be total overkill and too much code duplication.
3. Using macro would mean we use incomplete CSR names
examples: "status" for "mstatus"/"sstatus", "epc" for "mepc"/"sepc", etc. This means we cannot grep code for use of a CSR. I think this is less readable compared to using #ifdefQuoted 2 lines
Despite above reasons, above can always be attempted as separate patch.
Quoted 6 lines
On AArch64, we determine the current EL during runtime and then branch to respective labels for different ELs (see the
switch_elmacro for asm as well ascurrent_el()for C).Wouldn't it make sense to attempt something similar with S-mode, so that the same binary can run either in M or in S depending on how it was started?
As-per my understand, there is no direct way of knowing current execution mode in RISC-V at runtime.
Of course, software can step from M to S/U using mret OR from S to U using sret. Further software running in U-mode can do ecall to S-mode and S-mode can do ecall to M-mode.
Software is generally written for a particular execution mode (M, S, or U).
Regards,
Anup
PATCH v5 1/4 riscv: Add kconfig option to run U-Boot in S-mode
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午8:38寫道:
Quoted 135 lines · Alexander Graf
Quoted 133 lines · Anup Patel
Quoted 129 lines · Rick Chen
Quoted 113 lines
Quoted 94 lines
Quoted 94 lines
Subject: [PATCH v5 1/4] riscv: Add kconfig option to run U-Boot in S-mode
This patch adds kconfig option
RISCV_SMODEto run U-Boot in S-mode. When this opition is enabled we use s<xyz> CSRs instead of m<xyz> CSRs.It is important to note that there is no equivalent S-mode CSR for misa and mhartid CSRs so we expect M-mode runtime firmware (BBL or equivalent) to emulate misa and mhartid CSR read.
In-future, we will have more patches to avoid accessing misa and mhartid CSRs from S-mode.
Signed-off-by Anup Patel <[email protected]>Reviewed-by Bin Meng <[email protected]>Tested-by Bin Meng <[email protected]>Reviewed-by Lukas Auer <[email protected]>--- arch/riscv/Kconfig | 5 +++++ arch/riscv/cpu/start.S | 33 ++++++++++++++++++++++++++++ arch/riscv/include/asm/encoding.h | 2 ++ arch/riscv/lib/interrupts.c | 36 +++++++++++++++++++++++-------- 4 files changed, 67 insertions(+), 9 deletions(-)arch/riscv/Kconfig index 3e0af55e71..732a357a99 renamed from arch/riscv/Kconfig +0
-0100644
arch/riscv/Kconfig +5
-0@@ -55,6 +55,11 @@ config RISCV_ISA_C config RISCV_ISA_A def_bool y +config RISCV_SMODE + bool "Run in S-Mode" + help + Enable this option to build U-Boot for RISC-V S-Mode + config 32BIT boolarch/riscv/cpu/start.S index renamed from arch/riscv/cpu/start.S +0
-0
15e1b8199a..704190f946100644arch/riscv/cpu/start.S +21
-0@@ -41,10 +41,18 @@ _start: li t0, CONFIG_SYS_SDRAM_BASE SREG a2, 0(t0) la t0, trap_entry +#ifdef CONFIG_RISCV_SMODE + csrw stvec, t0 +#else csrw mtvec, t0 +#endif /* mask all interrupts */ +#ifdef CONFIG_RISCV_SMODE + csrw sie, zero +#else csrw mie, zero +#endif /* Enable cache */ jal icache_enable@@ -166,7 +174,11 @@ fix_rela_dyn: */ la t0, trap_entry add t0, t0, t6 +#ifdef CONFIG_RISCV_SMODE + csrw stvec, t0 +#else csrw mtvec, t0 +#endif clear_bss: la t0, __bss_start /* t0 <- rel __bss_start in FLASH */@@ -238,17 +250,34 @@ trap_entry: SREG x29, 29*REGBYTES(sp) SREG x30, 30*REGBYTES(sp) SREG x31, 31*REGBYTES(sp) +#ifdef CONFIG_RISCV_SMODE + csrr a0, scause + csrr a1, sepc +#else csrr a0, mcause csrr a1, mepc +#endif mv a2, sp jal handle_trap +#ifdef CONFIG_RISCV_SMODE + csrw sepc, a0 +#else csrw mepc, a0 +#endifQuoted 13 lines
arch/riscv/cpu/start.S trap_entry: · line 280
Quoted 13 lines
arch/riscv/cpu/start.S +8
-0+#ifdef CONFIG_RISCV_SMODE +/* + * Remain in S-mode after sret + */ + li t0, SSTATUS_SPP + csrs sstatus, t0 +#else /* * Remain in M-mode after mret */ li t0, MSTATUS_MPP csrs mstatus, t0 +#endifIt only the difference between s and m in csr. The code seem to be duplicate too much. Can you implement it in macro ?
or consider to separate it in different .S fileQuoted 2 lines
It may too complex to maintain in the future.
Here are few reasons why not to do this:
1. We don't have same set of CSRs for M-mode and S-mode. For certain, M-mode CSRs we don't have any corresponding S-mode CSRs.
2. Number of CSRs for each mode are really few so there won't be much #ifdef in code. Having separate .S will be total overkill and too much code duplication.
3. Using macro would mean we use incomplete CSR names
examples: "status" for "mstatus"/"sstatus", "epc" for "mepc"/"sepc", etc. This means we cannot grep code for use of a CSR. I think this is less readable compared to using #ifdef
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Despite above reasons, above can always be attempted as separate patch.
Hi Anup
I mean it is not a good way to switch s and m mode like that #ifdef CONFIG_RISCV_SMODE
csrw sepc, a0
#else
csrw mepc, a0
#endif
You can use ## to get stvec ot mtvec in different CONFIG It can be refered to some kernel code as below:glue.h
#define ____glue(name,fn) name##fn
#define __glue(name,fn) ____glue(name,fn)
glue-proc.h
#ifdef CONFIG_CPU_ARM720T
#define CPU_NAME cpu_arm720
#else
#define CPU_NAME cpu_arm7tdmi
#endif
#define cpu_proc_init __glue(CPU_NAME,_proc_init)
Then It will compile as cpu_arm720_proc_init or cpu_arm7tdmi_proc_init in different configuration.
stvec and mtvce can be implement by the same way.
B.R
Rick
Quoted 18 lines
Quoted 6 lines
On AArch64, we determine the current EL during runtime and then branch to respective labels for different ELs (see the
switch_elmacro for asm as well ascurrent_el()for C).Wouldn't it make sense to attempt something similar with S-mode, so that the same binary can run either in M or in S depending on how it was started?
As-per my understand, there is no direct way of knowing current execution mode in RISC-V at runtime.
Of course, software can step from M to S/U using mret OR from S to U using sret. Further software running in U-mode can do ecall to S-mode and S-mode can do ecall to M-mode.
Software is generally written for a particular execution mode (M, S, or U).
Regards,
Anup
PATCH v5 1/4 riscv: Add kconfig option to run U-Boot in S-mode
Quoted 164 lines · Rick Chen
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午8:38寫道:
Quoted 135 lines · Alexander Graf
Quoted 133 lines · Anup Patel
Quoted 129 lines · Rick Chen
Quoted 113 lines
Quoted 94 lines
Quoted 94 lines
Subject: [PATCH v5 1/4] riscv: Add kconfig option to run U-Boot in S-mode
This patch adds kconfig option
RISCV_SMODEto run U-Boot in S-mode. When this opition is enabled we use s<xyz> CSRs instead of m<xyz> CSRs.It is important to note that there is no equivalent S-mode CSR for misa and mhartid CSRs so we expect M-mode runtime firmware (BBL or equivalent) to emulate misa and mhartid CSR read.
In-future, we will have more patches to avoid accessing misa and mhartid CSRs from S-mode.
Signed-off-by Anup Patel <[email protected]>Reviewed-by Bin Meng <[email protected]>Tested-by Bin Meng <[email protected]>Reviewed-by Lukas Auer <[email protected]>--- arch/riscv/Kconfig | 5 +++++ arch/riscv/cpu/start.S | 33 ++++++++++++++++++++++++++++ arch/riscv/include/asm/encoding.h | 2 ++ arch/riscv/lib/interrupts.c | 36 +++++++++++++++++++++++-------- 4 files changed, 67 insertions(+), 9 deletions(-)arch/riscv/Kconfig index 3e0af55e71..732a357a99 renamed from arch/riscv/Kconfig +0
-0100644
arch/riscv/Kconfig +5
-0@@ -55,6 +55,11 @@ config RISCV_ISA_C config RISCV_ISA_A def_bool y +config RISCV_SMODE + bool "Run in S-Mode" + help + Enable this option to build U-Boot for RISC-V S-Mode + config 32BIT boolarch/riscv/cpu/start.S index renamed from arch/riscv/cpu/start.S +0
-0
15e1b8199a..704190f946100644arch/riscv/cpu/start.S +21
-0@@ -41,10 +41,18 @@ _start: li t0, CONFIG_SYS_SDRAM_BASE SREG a2, 0(t0) la t0, trap_entry +#ifdef CONFIG_RISCV_SMODE + csrw stvec, t0 +#else csrw mtvec, t0 +#endif /* mask all interrupts */ +#ifdef CONFIG_RISCV_SMODE + csrw sie, zero +#else csrw mie, zero +#endif /* Enable cache */ jal icache_enable@@ -166,7 +174,11 @@ fix_rela_dyn: */ la t0, trap_entry add t0, t0, t6 +#ifdef CONFIG_RISCV_SMODE + csrw stvec, t0 +#else csrw mtvec, t0 +#endif clear_bss: la t0, __bss_start /* t0 <- rel __bss_start in FLASH */@@ -238,17 +250,34 @@ trap_entry: SREG x29, 29*REGBYTES(sp) SREG x30, 30*REGBYTES(sp) SREG x31, 31*REGBYTES(sp) +#ifdef CONFIG_RISCV_SMODE + csrr a0, scause + csrr a1, sepc +#else csrr a0, mcause csrr a1, mepc +#endif mv a2, sp jal handle_trap +#ifdef CONFIG_RISCV_SMODE + csrw sepc, a0 +#else csrw mepc, a0 +#endifQuoted 13 lines
arch/riscv/cpu/start.S trap_entry: · line 280
Quoted 13 lines
arch/riscv/cpu/start.S +8
-0+#ifdef CONFIG_RISCV_SMODE +/* + * Remain in S-mode after sret + */ + li t0, SSTATUS_SPP + csrs sstatus, t0 +#else /* * Remain in M-mode after mret */ li t0, MSTATUS_MPP csrs mstatus, t0 +#endifIt only the difference between s and m in csr. The code seem to be duplicate too much. Can you implement it in macro ?
or consider to separate it in different .S fileQuoted 2 lines
It may too complex to maintain in the future.
Here are few reasons why not to do this:
1. We don't have same set of CSRs for M-mode and S-mode. For certain, M-mode CSRs we don't have any corresponding S-mode CSRs.
2. Number of CSRs for each mode are really few so there won't be much #ifdef in code. Having separate .S will be total overkill and too much code duplication.
3. Using macro would mean we use incomplete CSR names
examples: "status" for "mstatus"/"sstatus", "epc" for "mepc"/"sepc", etc. This means we cannot grep code for use of a CSR. I think this is less readable compared to using #ifdefQuoted 3 lines
Quoted 3 lines
Quoted 2 lines
Despite above reasons, above can always be attempted as separate patch.
Hi Anup
I mean it is not a good way to switch s and m mode like that #ifdef
CONFIG_RISCV_SMODE
csrw sepc, a0
#else
csrw mepc, a0
#endifYou can use ## to get stvec ot mtvec in different CONFIG It can be refered to some kernel code as below:
glue.h
#define____glue(name,fn)name##fn
#define__glue(name,fn)____glue(name,fn)
glue-proc.h
#ifdefCONFIG_CPU_ARM720T
#defineCPU_NAMEcpu_arm720
#else
#defineCPU_NAMEcpu_arm7tdmi
#endif
Quoted 5 lines
#define
cpu_proc_init__glue(CPU_NAME,_proc_init)Then It will compile as
cpu_arm720_proc_initorcpu_arm7tdmi_proc_initin different configuration.
stvec and mtvce can be implement by the same way.
I had understood your suggestion previously.
Though I am not fan of this approach, I will change it anyway.
Thanks,
Anup
PATCH v5 2/4 riscv: qemu: Use different SYS_TEXT_BASE for S-mode
In reply to Anup PatelWhen u-boot runs in S-mode, the M-mode runtime firmware (BBL or equivalent) uses memory range in 0x80000000 to 0x80200000. Due to this, we cannot use 0x80000000 as SYS_TEXT_BASE when running in S-mode. Instead for S-mode, we use 0x80200000 as SYS_TEXT_BASE.
Even Linux RISC-V kernel ignores/reserves memory range 0x80000000 to 0x80200000 because it runs in S-mode.
--- board/emulation/qemu-riscv/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
board/emulation/qemu-riscv/Kconfig +2 -1
@@ -13,7 +13,8 @@ config SYS_CONFIG_NAME default "qemu-riscv" config SYS_TEXT_BASE - default 0x80000000 + default 0x80000000 if !RISCV_SMODE + default 0x80200000 if RISCV_SMODE config BOARD_SPECIFIC_OPTIONS # dummy def_bool y
Signature · 1 line
2.17.1
PATCH v5 3/4 riscv: Add S-mode defconfigs for QEMU virt machine
In reply to Anup PatelThis patch adds S-mode defconfigs for QEMU virt machine so that we can run u-boot in S-mode on QEMU using M-mode runtime firmware (BBL or equivalent).
--- board/emulation/qemu-riscv/MAINTAINERS | 2 ++ configs/qemu-riscv32_smode_defconfig | 10 ++++++++++ configs/qemu-riscv64_smode_defconfig | 11 +++++++++++ 3 files changed, 23 insertions(+) create mode 100644 configs/qemu-riscv32_smode_defconfig create mode 100644 configs/qemu-riscv64_smode_defconfig
board/emulation/qemu-riscv/MAINTAINERS +2 -0
@@ -4,4 +4,6 @@ S: Maintained F: board/emulation/qemu-riscv/ F: include/configs/qemu-riscv.h F: configs/qemu-riscv32_defconfig +F: configs/qemu-riscv32_smode_defconfig F: configs/qemu-riscv64_defconfig +F: configs/qemu-riscv64_smode_defconfig
configs/qemu-riscv32_smode_defconfig new file +10 -0
@@ -0,0 +1,10 @@ +CONFIG_RISCV=y +CONFIG_TARGET_QEMU_VIRT=y +CONFIG_RISCV_SMODE=y +CONFIG_DISTRO_DEFAULTS=y +CONFIG_NR_DRAM_BANKS=1 +CONFIG_FIT=y +CONFIG_DISPLAY_CPUINFO=y +CONFIG_DISPLAY_BOARDINFO=y +# CONFIG_CMD_MII is not set +CONFIG_OF_PRIOR_STAGE=y
configs/qemu-riscv64_smode_defconfig new file +11 -0
@@ -0,0 +1,11 @@ +CONFIG_RISCV=y +CONFIG_TARGET_QEMU_VIRT=y +CONFIG_ARCH_RV64I=y +CONFIG_RISCV_SMODE=y +CONFIG_DISTRO_DEFAULTS=y +CONFIG_NR_DRAM_BANKS=1 +CONFIG_FIT=y +CONFIG_DISPLAY_CPUINFO=y +CONFIG_DISPLAY_BOARDINFO=y +# CONFIG_CMD_MII is not set +CONFIG_OF_PRIOR_STAGE=y
Signature · 1 line
2.17.1
PATCH v5 4/4 riscv: Remove redundant a2 store on DRAM base in start.S
In reply to Anup PatelCurrently, the RISC-V U-Boot is saving a2 register at CONFIG_SYS_DRAM_BASE in start.S which does not make sense because there is no information passed by previous booting stage in a2 register.
This patch removes redundant a2 store on DRAM base.
--- arch/riscv/cpu/start.S | 2 -- 1 file changed, 2 deletions(-)
arch/riscv/cpu/start.S +0 -2
@@ -38,8 +38,6 @@ _start: mv s0, a0 mv s1, a1 - li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0) la t0, trap_entry #ifdef CONFIG_RISCV_SMODE csrw stvec, t0
Signature · 1 line
2.17.1
PATCH v5 4/4 riscv: Remove redundant a2 store on DRAM base in start.S
Quoted 18 lines · Anup Patel
Currently, the RISC-V U-Boot is saving a2 register at
CONFIG_SYS_DRAM_BASEinstart.Swhich does not make sense because there is no information passed by previous booting stage in a2 register.This patch removes redundant a2 store on DRAM base.
Signed-off-by Anup Patel <[email protected]>--- arch/riscv/cpu/start.S | 2 -- 1 file changed, 2 deletions(-)arch/riscv/cpu/start.S +0
-0
arch/riscv/cpu/start.S _start:
Quoted 9 lines
arch/riscv/cpu/start.S +0
-3@@ -38,8 +38,6 @@ _start: mv s0, a0 mv s1, a1 - li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0) la t0, trap_entry #ifdef CONFIG_RISCV_SMODE csrw stvec, t0 --
This is weird. I remember these two lines were already removed by Lukas's patch series before? Did not have time to dig out the history though.
Regards,
Bin
Auer
PATCH v5 4/4 riscv: Remove redundant a2 store on DRAM base in start.S
Quoted 34 lines · Bin Meng
Quoted 18 lines · Anup Patel
Currently, the RISC-V U-Boot is saving a2 register at
CONFIG_SYS_DRAM_BASEinstart.Swhich does not make sense because there is no information passed by previous booting stage in a2 register.This patch removes redundant a2 store on DRAM base.
Signed-off-by Anup Patel <[email protected]>--- arch/riscv/cpu/start.S | 2 -- 1 file changed, 2 deletions(-)arch/riscv/cpu/start.S +0
-0arch/riscv/cpu/start.S _start:
Quoted 9 lines
arch/riscv/cpu/start.S +0
-3@@ -38,8 +38,6 @@ _start: mv s0, a0 mv s1, a1 - li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0) la t0, trap_entry #ifdef CONFIG_RISCV_SMODE csrw stvec, t0 --This is weird. I remember these two lines were already removed by Lukas's patch series before? Did not have time to dig out the history though.
Quoted 2 lines
Regards,
Bin
You are correct, however I removed it again, because I did not want to break Rick's board. He did add a commit to the last pull request that removes these two lines and adjusts his board accordingly, but it is not in the current one.
Thanks,
Lukas
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v5 4/4 riscv: Remove redundant a2 store on DRAM base in start.S
Quoted 32 lines
Quoted 31 lines
Quoted 31 lines
Quoted 17 lines
Currently, the RISC-V U-Boot is saving a2 register at
CONFIG_SYS_DRAM_BASEinstart.Swhich does not make sense because there is no information passed by previous booting stage in a2 register.This patch removes redundant a2 store on DRAM base.
Signed-off-by Anup Patel <[email protected]>--- arch/riscv/cpu/start.S | 2 -- 1 file changed, 2 deletions(-)arch/riscv/cpu/start.S index renamed from arch/riscv/cpu/start.S +0
-0
704190f946..e4276e8e19100644arch/riscv/cpu/start.S _start:
Quoted 9 lines
arch/riscv/cpu/start.S +0
-3@@ -38,8 +38,6 @@ _start: mv s0, a0 mv s1, a1 - li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0) la t0, trap_entry #ifdef CONFIG_RISCV_SMODE csrw stvec, t0 --This is weird. I remember these two lines were already removed by Lukas's patch series before? Did not have time to dig out the history though.
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Regards,
BinYou are correct, however I removed it again, because I did not want to break Rick's board. He did add a commit to the last pull request that removes these two lines and adjusts his board accordingly, but it is not in the current one.
Hi Likas
Thanks for your explanation.
RIck's commit as below
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.html
B.R
Rick
Quoted 2 lines
Quoted 2 lines
Thanks,
Lukas
PATCH v5 4/4 riscv: Remove redundant a2 store on DRAM base in start.S
Quoted 41 lines · Rick Chen
Quoted 33 lines
Quoted 32 lines
Quoted 32 lines
Quoted 18 lines
Currently, the RISC-V U-Boot is saving a2 register at
CONFIG_SYS_DRAM_BASEinstart.Swhich does not make sense because there is no information passed by previous booting stage in a2 register.This patch removes redundant a2 store on DRAM base.
Signed-off-by Anup Patel <[email protected]>--- arch/riscv/cpu/start.S | 2 -- 1 file changed, 2 deletions(-)arch/riscv/cpu/start.S index renamed from arch/riscv/cpu/start.S +0
-0
704190f946..e4276e8e19100644arch/riscv/cpu/start.S _start:
Quoted 9 lines
arch/riscv/cpu/start.S +0
-3@@ -38,8 +38,6 @@ _start: mv s0, a0 mv s1, a1 - li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0) la t0, trap_entry #ifdef CONFIG_RISCV_SMODE csrw stvec, t0 --This is weird. I remember these two lines were already removed by Lukas's patch series before? Did not have time to dig out the history though.
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Regards,
BinYou are correct, however I removed it again, because I did not want to break Rick's board. He did add a commit to the last pull request that removes these two lines and adjusts his board accordingly, but it is not in the current one.
Quoted 6 lines
Hi Likas
Thanks for your explanation.
RIck's commit as below
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.html
When we run U-Boot in S-mode the BBL runs from 0x80000000 so this two lines corrupts BBL instructions.
If this is important for some board then please have it around #ifdef.
My apologies for the noise.
Regards,
Anup
PATCH v5 4/4 riscv: Remove redundant a2 store on DRAM base in start.S
Anup Patel <[email protected]> 於 2018年11月27日 週二 上午11:28寫道:
Quoted 47 lines · Rick Chen
Quoted 45 lines
Quoted 33 lines
Quoted 32 lines
Quoted 32 lines
Quoted 18 lines
Currently, the RISC-V U-Boot is saving a2 register at
CONFIG_SYS_DRAM_BASEinstart.Swhich does not make sense because there is no information passed by previous booting stage in a2 register.This patch removes redundant a2 store on DRAM base.
Signed-off-by Anup Patel <[email protected]>--- arch/riscv/cpu/start.S | 2 -- 1 file changed, 2 deletions(-)arch/riscv/cpu/start.S index renamed from arch/riscv/cpu/start.S +0
-0
704190f946..e4276e8e19100644arch/riscv/cpu/start.S _start:
Quoted 9 lines
arch/riscv/cpu/start.S +0
-3@@ -38,8 +38,6 @@ _start: mv s0, a0 mv s1, a1 - li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0) la t0, trap_entry #ifdef CONFIG_RISCV_SMODE csrw stvec, t0 --This is weird. I remember these two lines were already removed by Lukas's patch series before? Did not have time to dig out the history though.
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Regards,
BinYou are correct, however I removed it again, because I did not want to break Rick's board. He did add a commit to the last pull request that removes these two lines and adjusts his board accordingly, but it is not in the current one.
Hi Likas
Thanks for your explanation.
Quoted 8 lines
Quoted 2 lines
RIck's commit as below
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlWhen we run U-Boot in S-mode the BBL runs from
0x80000000so this two lines corrupts BBL instructions.If this is important for some board then please have it around #ifdef.
Hi Anup
In the discussion as below :
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.html
I try to solve this issue with the aptch
[PATCH] riscv: ax25-ae350: Pass dtb address to u-boot with a1 register
arch/riscv/cpu/start.S +0 -0
- li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0)
(quoted diff) +0 -0
b/board/AndesTech/ax25-ae350/ax25-ae350.c
void *board_fdt_blob_setup(void)
{
- void **ptr = (void *)CONFIG_SYS_SDRAM_BASE;
+ void **ptr = (void *)&prior_stage_fdt_address;
in the previous pull request.
But Bin do not agree with that I use prior_stage_fdt_address in board_fdt_blob_setup( )
I try to explain why I use it like that way.
Then Bin have not any reply in the following mail. Finally I decide to drop this patch in the next pull request.
Hi Bin
How do you think about I recovery this patch to fix this issue ?
B.R
Rick
Quoted 4 lines
My apologies for the noise.
Regards,
Anup
PATCH v5 4/4 riscv: Remove redundant a2 store on DRAM base in start.S
Quoted 84 lines · Rick Chen
Anup Patel <[email protected]> 於 2018年11月27日 週二 上午11:28寫道:
Quoted 47 lines · Rick Chen
Quoted 45 lines
Quoted 33 lines
Quoted 32 lines
Quoted 32 lines
Quoted 18 lines
Currently, the RISC-V U-Boot is saving a2 register at
CONFIG_SYS_DRAM_BASEinstart.Swhich does not make sense because there is no information passed by previous booting stage in a2 register.This patch removes redundant a2 store on DRAM base.
Signed-off-by Anup Patel <[email protected]>--- arch/riscv/cpu/start.S | 2 -- 1 file changed, 2 deletions(-)arch/riscv/cpu/start.S index renamed from arch/riscv/cpu/start.S +0
-0
704190f946..e4276e8e19100644arch/riscv/cpu/start.S _start:
Quoted 9 lines
arch/riscv/cpu/start.S +0
-3@@ -38,8 +38,6 @@ _start: mv s0, a0 mv s1, a1 - li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0) la t0, trap_entry #ifdef CONFIG_RISCV_SMODE csrw stvec, t0 --This is weird. I remember these two lines were already removed by Lukas's patch series before? Did not have time to dig out the history though.
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Regards,
BinYou are correct, however I removed it again, because I did not want to break Rick's board. He did add a commit to the last pull request that removes these two lines and adjusts his board accordingly, but it is not in the current one.
Hi Likas
Thanks for your explanation.
Quoted 8 lines
Quoted 2 lines
RIck's commit as below
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlWhen we run U-Boot in S-mode the BBL runs from
0x80000000so this two lines corrupts BBL instructions.If this is important for some board then please have it around #ifdef.
Hi Anup
In the discussion as below :
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlI try to solve this issue with the aptch
[PATCH] riscv: ax25-ae350: Pass dtb address to u-boot with a1 registerarch/riscv/cpu/start.S +0
-2- li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0)board/AndesTech/ax25-ae350/ax25-ae350.c +1
-1void *board_fdt_blob_setup (void ) { -void **ptr = (void *)CONFIG_SYS_SDRAM_BASE ; +void **ptr = (void *)&prior_stage_fdt_address;in the previous pull request.
But Bin do not agree with that I use
prior_stage_fdt_addressinboard_fdt_blob_setup( )
I try to explain why I use it like that way.
Then Bin have not any reply in the following mail. Finally I decide to drop this patch in the next pull request.
Quoted 3 lines
Hi Bin
How do you think about I recovery this patch to fix this issue ?
Actually, previous booting stage can pass location of FDT stored in flash to U-Boot. U-Boot requires FDT at a DRAM location which it can modify in-place before passing on to Linux kernel so we should relocate the FDT passed by previous booting stage to some board specific DRAM location.
My suggestion is as follows:
Instead of SDRAM_BASE, we can have new board specific config CONFIG_RISCV_PRIOR_FDT_BASE
If CONFIG_RISCV_PRIOR_FDT_BASE is defined/selected by config then in start.S copy-over the FDT from location pointed by "a1" register to location pointed by CONFIG_RISCV_PRIOR_FDT_BASE.
In your board_fdt_blob_setup(), you can safely do:
void **ptr = (void *)CONFIG_RISCV_PRIOR_FDT_BASE;
Regards,
Anup
PATCH v5 4/4 riscv: Remove redundant a2 store on DRAM base in start.S
Quoted 95 lines · Anup Patel
Quoted 84 lines · Rick Chen
Anup Patel <[email protected]> 於 2018年11月27日 週二 上午11:28寫道:
Quoted 47 lines · Rick Chen
Quoted 45 lines
Quoted 33 lines
Quoted 32 lines
Quoted 32 lines
Quoted 18 lines
Currently, the RISC-V U-Boot is saving a2 register at
CONFIG_SYS_DRAM_BASEinstart.Swhich does not make sense because there is no information passed by previous booting stage in a2 register.This patch removes redundant a2 store on DRAM base.
Signed-off-by Anup Patel <[email protected]>--- arch/riscv/cpu/start.S | 2 -- 1 file changed, 2 deletions(-)arch/riscv/cpu/start.S index renamed from arch/riscv/cpu/start.S +0
-0
704190f946..e4276e8e19100644arch/riscv/cpu/start.S _start:
Quoted 9 lines
arch/riscv/cpu/start.S +0
-3@@ -38,8 +38,6 @@ _start: mv s0, a0 mv s1, a1 - li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0) la t0, trap_entry #ifdef CONFIG_RISCV_SMODE csrw stvec, t0 --This is weird. I remember these two lines were already removed by Lukas's patch series before? Did not have time to dig out the history though.
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Regards,
BinYou are correct, however I removed it again, because I did not want to break Rick's board. He did add a commit to the last pull request that removes these two lines and adjusts his board accordingly, but it is not in the current one.
Hi Likas
Thanks for your explanation.
Quoted 8 lines
Quoted 2 lines
RIck's commit as below
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlWhen we run U-Boot in S-mode the BBL runs from
0x80000000so this two lines corrupts BBL instructions.If this is important for some board then please have it around #ifdef.
Hi Anup
In the discussion as below :
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlI try to solve this issue with the aptch
[PATCH] riscv: ax25-ae350: Pass dtb address to u-boot with a1 registerarch/riscv/cpu/start.S +0
-2- li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0)board/AndesTech/ax25-ae350/ax25-ae350.c +1
-1void *board_fdt_blob_setup (void ) { -void **ptr = (void *)CONFIG_SYS_SDRAM_BASE ; +void **ptr = (void *)&prior_stage_fdt_address;in the previous pull request.
But Bin do not agree with that I use
prior_stage_fdt_addressinboard_fdt_blob_setup( )
I try to explain why I use it like that way.
Then Bin have not any reply in the following mail. Finally I decide to drop this patch in the next pull request.Quoted 3 lines
Hi Bin
How do you think about I recovery this patch to fix this issue ?
Actually, previous booting stage can pass location of FDT stored in flash to U-Boot. U-Boot requires FDT at a DRAM location which it can modify in-place before passing on to Linux kernel so we should relocate the FDT passed by previous booting stage to some board specific DRAM location.
Quoted 8 lines
My suggestion is as follows:
Instead of
SDRAM_BASE, we can have new board specific configCONFIG_RISCV_PRIOR_FDT_BASEIf
CONFIG_RISCV_PRIOR_FDT_BASEis defined/selected by config then instart.Scopy-over the FDT from location pointed by "a1" register to location pointed byCONFIG_RISCV_PRIOR_FDT_BASE.
I think you can copy-over FDT in C code too. You don't need to do in start.S.
Quoted 6 lines
In your
board_fdt_blob_setup(), you can safely do:
void **ptr = (void *)CONFIG_RISCV_PRIOR_FDT_BASE;Regards,
Anup
PATCH v5 4/4 riscv: Remove redundant a2 store on DRAM base in start.S
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午1:47寫道:
Quoted 97 lines · Anup Patel
Quoted 95 lines · Rick Chen
Quoted 84 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 上午11:28寫道:
Quoted 47 lines · Rick Chen
Quoted 45 lines
Quoted 33 lines
Quoted 32 lines
Quoted 32 lines
Quoted 18 lines
Currently, the RISC-V U-Boot is saving a2 register at
CONFIG_SYS_DRAM_BASEinstart.Swhich does not make sense because there is no information passed by previous booting stage in a2 register.This patch removes redundant a2 store on DRAM base.
Signed-off-by Anup Patel <[email protected]>--- arch/riscv/cpu/start.S | 2 -- 1 file changed, 2 deletions(-)arch/riscv/cpu/start.S index renamed from arch/riscv/cpu/start.S +0
-0
704190f946..e4276e8e19100644arch/riscv/cpu/start.S _start:
Quoted 9 lines
arch/riscv/cpu/start.S +0
-3@@ -38,8 +38,6 @@ _start: mv s0, a0 mv s1, a1 - li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0) la t0, trap_entry #ifdef CONFIG_RISCV_SMODE csrw stvec, t0 --This is weird. I remember these two lines were already removed by Lukas's patch series before? Did not have time to dig out the history though.
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Regards,
BinYou are correct, however I removed it again, because I did not want to break Rick's board. He did add a commit to the last pull request that removes these two lines and adjusts his board accordingly, but it is not in the current one.
Hi Likas
Thanks for your explanation.
Quoted 8 lines
Quoted 2 lines
RIck's commit as below
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlWhen we run U-Boot in S-mode the BBL runs from
0x80000000so this two lines corrupts BBL instructions.If this is important for some board then please have it around #ifdef.
Hi Anup
In the discussion as below :
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlI try to solve this issue with the aptch
[PATCH] riscv: ax25-ae350: Pass dtb address to u-boot with a1 registerarch/riscv/cpu/start.S +0
-2- li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0)board/AndesTech/ax25-ae350/ax25-ae350.c +1
-1void *board_fdt_blob_setup (void ) { -void **ptr = (void *)CONFIG_SYS_SDRAM_BASE ; +void **ptr = (void *)&prior_stage_fdt_address;in the previous pull request.
But Bin do not agree with that I use
prior_stage_fdt_addressinboard_fdt_blob_setup( )
I try to explain why I use it like that way.
Then Bin have not any reply in the following mail. Finally I decide to drop this patch in the next pull request.Quoted 3 lines
Hi Bin
How do you think about I recovery this patch to fix this issue ?
Actually, previous booting stage can pass location of FDT stored in flash to U-Boot. U-Boot requires FDT at a DRAM location which it can modify in-place before passing on to Linux kernel so we should relocate the FDT passed by previous booting stage to some board specific DRAM location.
Quoted 9 lines
Quoted 8 lines
My suggestion is as follows:
Instead of
SDRAM_BASE, we can have new board specific configCONFIG_RISCV_PRIOR_FDT_BASEIf
CONFIG_RISCV_PRIOR_FDT_BASEis defined/selected by config then instart.Scopy-over the FDT from location pointed by "a1" register to location pointed byCONFIG_RISCV_PRIOR_FDT_BASE.
Hi Anup
It can not achieve dtb delivery at runtime.
Rick
Quoted 9 lines
I think you can copy-over FDT in C code too. You don't need to do in
start.S.Quoted 6 lines
In your
board_fdt_blob_setup(), you can safely do:
void **ptr = (void *)CONFIG_RISCV_PRIOR_FDT_BASE;Regards,
Anup
PATCH v5 4/4 riscv: Remove redundant a2 store on DRAM base in start.S
Quoted 117 lines · On Tue, 27 Nov, 2018, 11:38 AM Rick Chen <[email protected] wrote:
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午1:47寫道:
Quoted 4 lines · Anup Patel
Quoted 2 lines
On Tue, Nov 27, 2018 at 10:50 AM Rick Chen <[email protected]>
Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 上午11:28寫道:
Quoted 2 lines
On Tue, Nov 27, 2018 at 8:50 AM Rick Chen <[email protected]>
Quoted 3 lines · wrote:
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Currently, the RISC-V U-Boot is saving a2 register at
CONFIG_SYS_DRAM_BASEinstart.Swhich does not makesense because
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
there is no information passed by previous booting stage
in a2
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Review
Quoted 10 lines
register.
This patch removes redundant a2 store on DRAM base.
Signed-off-by Anup Patel <[email protected]>--- arch/riscv/cpu/start.S | 2 -- 1 file changed, 2 deletions(-)(quoted diff) +0
-0
b/arch/riscv/cpu/start.SindexQuoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
704190f946..e4276e8e19100644arch/riscv/cpu/start.S +0
-0@@ -38,8 +38,6 @@ _start: mv s0, a0 mv s1, a1Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
arch/riscv/cpu/start.S _start:
Quoted 6 lines
arch/riscv/cpu/start.S +0
-3- li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0) la t0, trap_entry #ifdef CONFIG_RISCV_SMODE csrw stvec, t0 --This is weird. I remember these two lines were already
removed by
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Lukas's patch series before? Did not have time to dig out
the history
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
though.
Regards,
BinYou are correct, however I removed it again, because I did
not want to break
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Rick's board. He did add a commit to the last pull request
that removes these
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
two lines and adjusts his board accordingly, but it is not
in the current one.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Hi Likas
Thanks for your explanation.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
RIck's commit as below
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlWhen we run U-Boot in S-mode the BBL runs from
0x80000000so this two lines corrupts BBL instructions.If this is important for some board then please have it around
#ifdef.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 1 line
Hi Anup
In the discussion as below :
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlI try to solve this issue with the aptch
[PATCH] riscv: ax25-ae350: Pass dtb address to u-boot with a1register
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
arch/riscv/cpu/start.S +0
-2- li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0)board/AndesTech/ax25-ae350/ax25-ae350.c +1
-1void *board_fdt_blob_setup (void ) { -void **ptr = (void *)CONFIG_SYS_SDRAM_BASE ; +void **ptr = (void *)&prior_stage_fdt_address;in the previous pull request.
But Bin do not agree with that I use
prior_stage_fdt_addressinboard_fdt_blob_setup( )
I try to explain why I use it like that way.
Then Bin have not any reply in the following mail. Finally I decide to drop this patch in the next pull request.Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Hi Bin
How do you think about I recovery this patch to fix this issue ?
Actually, previous booting stage can pass location of FDT stored in
flash
Quoted 2 lines
Quoted 2 lines
to U-Boot. U-Boot requires FDT at a DRAM location which it can modify in-place before passing on to Linux kernel so we should relocate the
FDT
Quoted 7 lines
Quoted 7 lines
passed by previous booting stage to some board specific DRAM location.
My suggestion is as follows:
Instead of
SDRAM_BASE, we can have new board specific configCONFIG_RISCV_PRIOR_FDT_BASE
Quoted 9 lines
Quoted 4 lines
Quoted 3 lines
If
CONFIG_RISCV_PRIOR_FDT_BASEis defined/selected by config then instart.Scopy-over the FDT from location pointed by "a1" register to location pointed byCONFIG_RISCV_PRIOR_FDT_BASE.Hi Anup
It can not achieve dtb delivery at runtime.
Can you elaborate why?
I am sure we can always relocate FDT passed by previous stage to some safer location and use it from there.
Regards,
Anup
Quoted 12 lines
Rick
Quoted 9 lines
I think you can copy-over FDT in C code too. You don't need to do in
start.S.Quoted 6 lines
In your
board_fdt_blob_setup(), you can safely do:
void **ptr = (void *)CONFIG_RISCV_PRIOR_FDT_BASE;Regards,
Anup
PATCH v5 4/4 riscv: Remove redundant a2 store on DRAM base in start.S
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午2:14寫道:
Quoted 113 lines · On Tue, 27 Nov, 2018, 11:38 AM Rick Chen <[email protected] wrote:
Quoted 109 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午1:47寫道:
Quoted 106 lines · Anup Patel
Quoted 103 lines · Rick Chen
Quoted 84 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 上午11:28寫道:
Quoted 47 lines · Rick Chen
Quoted 45 lines
Quoted 33 lines
Quoted 32 lines
Quoted 32 lines
Quoted 18 lines
Currently, the RISC-V U-Boot is saving a2 register at
CONFIG_SYS_DRAM_BASEinstart.Swhich does not make sense because there is no information passed by previous booting stage in a2 register.This patch removes redundant a2 store on DRAM base.
Signed-off-by Anup Patel <[email protected]>--- arch/riscv/cpu/start.S | 2 -- 1 file changed, 2 deletions(-)arch/riscv/cpu/start.S index renamed from arch/riscv/cpu/start.S +0
-0
704190f946..e4276e8e19100644arch/riscv/cpu/start.S _start:
Quoted 9 lines
arch/riscv/cpu/start.S +0
-3@@ -38,8 +38,6 @@ _start: mv s0, a0 mv s1, a1 - li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0) la t0, trap_entry #ifdef CONFIG_RISCV_SMODE csrw stvec, t0 --This is weird. I remember these two lines were already removed by Lukas's patch series before? Did not have time to dig out the history though.
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Regards,
BinYou are correct, however I removed it again, because I did not want to break Rick's board. He did add a commit to the last pull request that removes these two lines and adjusts his board accordingly, but it is not in the current one.
Hi Likas
Thanks for your explanation.
Quoted 8 lines
Quoted 2 lines
RIck's commit as below
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlWhen we run U-Boot in S-mode the BBL runs from
0x80000000so this two lines corrupts BBL instructions.If this is important for some board then please have it around #ifdef.
Hi Anup
In the discussion as below :
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlI try to solve this issue with the aptch
[PATCH] riscv: ax25-ae350: Pass dtb address to u-boot with a1 registerarch/riscv/cpu/start.S +0
-2- li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0)board/AndesTech/ax25-ae350/ax25-ae350.c +1
-1void *board_fdt_blob_setup (void ) { -void **ptr = (void *)CONFIG_SYS_SDRAM_BASE ; +void **ptr = (void *)&prior_stage_fdt_address;in the previous pull request.
But Bin do not agree with that I use
prior_stage_fdt_addressinboard_fdt_blob_setup( )
I try to explain why I use it like that way.
Then Bin have not any reply in the following mail. Finally I decide to drop this patch in the next pull request.Quoted 3 lines
Hi Bin
How do you think about I recovery this patch to fix this issue ?
Actually, previous booting stage can pass location of FDT stored in flash to U-Boot. U-Boot requires FDT at a DRAM location which it can modify in-place before passing on to Linux kernel so we should relocate the FDT passed by previous booting stage to some board specific DRAM location.
My suggestion is as follows:
Instead of
SDRAM_BASE, we can have new board specific configCONFIG_RISCV_PRIOR_FDT_BASEIf
CONFIG_RISCV_PRIOR_FDT_BASEis defined/selected by config then instart.Scopy-over the FDT from location pointed by "a1" register to location pointed byCONFIG_RISCV_PRIOR_FDT_BASE.
Quoted 7 lines
Quoted 3 lines
Hi Anup
It can not achieve dtb delivery at runtime.
Can you elaborate why?
CONFIG_RISCV_PRIOR_FDT_BASE is determined at compile time. I am wondering how it can be modified at run time ?
Quoted 1 line
I am sure we can always relocate FDT passed by previous stage to some safer location and use it from there.
My original patch also can achieve that dtb passed by a1 and relocated and boot.
Quoted 16 lines
Regards,
AnupQuoted 12 lines
Rick
Quoted 9 lines
I think you can copy-over FDT in C code too. You don't need to do in
start.S.Quoted 6 lines
In your
board_fdt_blob_setup(), you can safely do:
void **ptr = (void *)CONFIG_RISCV_PRIOR_FDT_BASE;Regards,
Anup
PATCH v5 4/4 riscv: Remove redundant a2 store on DRAM base in start.S
Quoted 117 lines · Rick Chen
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午2:14寫道:
Quoted 115 lines · On Tue, 27 Nov, 2018, 11:38 AM Rick Chen <[email protected] wrote:
Quoted 111 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午1:47寫道:
Quoted 97 lines · Anup Patel
Quoted 95 lines · Rick Chen
Quoted 84 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 上午11:28寫道:
Quoted 47 lines · Rick Chen
Quoted 45 lines
Quoted 33 lines
Quoted 32 lines
Quoted 32 lines
Quoted 18 lines
Currently, the RISC-V U-Boot is saving a2 register at
CONFIG_SYS_DRAM_BASEinstart.Swhich does not make sense because there is no information passed by previous booting stage in a2 register.This patch removes redundant a2 store on DRAM base.
Signed-off-by Anup Patel <[email protected]>--- arch/riscv/cpu/start.S | 2 -- 1 file changed, 2 deletions(-)arch/riscv/cpu/start.S index renamed from arch/riscv/cpu/start.S +0
-0
704190f946..e4276e8e19100644arch/riscv/cpu/start.S _start:
Quoted 9 lines
arch/riscv/cpu/start.S +0
-3@@ -38,8 +38,6 @@ _start: mv s0, a0 mv s1, a1 - li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0) la t0, trap_entry #ifdef CONFIG_RISCV_SMODE csrw stvec, t0 --This is weird. I remember these two lines were already removed by Lukas's patch series before? Did not have time to dig out the history though.
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Regards,
BinYou are correct, however I removed it again, because I did not want to break Rick's board. He did add a commit to the last pull request that removes these two lines and adjusts his board accordingly, but it is not in the current one.
Hi Likas
Thanks for your explanation.
Quoted 8 lines
Quoted 2 lines
RIck's commit as below
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlWhen we run U-Boot in S-mode the BBL runs from
0x80000000so this two lines corrupts BBL instructions.If this is important for some board then please have it around #ifdef.
Hi Anup
In the discussion as below :
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlI try to solve this issue with the aptch
[PATCH] riscv: ax25-ae350: Pass dtb address to u-boot with a1 registerarch/riscv/cpu/start.S +0
-2- li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0)board/AndesTech/ax25-ae350/ax25-ae350.c +1
-1void *board_fdt_blob_setup (void ) { -void **ptr = (void *)CONFIG_SYS_SDRAM_BASE ; +void **ptr = (void *)&prior_stage_fdt_address;in the previous pull request.
But Bin do not agree with that I use
prior_stage_fdt_addressinboard_fdt_blob_setup( )
I try to explain why I use it like that way.
Then Bin have not any reply in the following mail. Finally I decide to drop this patch in the next pull request.Quoted 3 lines
Hi Bin
How do you think about I recovery this patch to fix this issue ?
Actually, previous booting stage can pass location of FDT stored in flash to U-Boot. U-Boot requires FDT at a DRAM location which it can modify in-place before passing on to Linux kernel so we should relocate the FDT passed by previous booting stage to some board specific DRAM location.
Quoted 9 lines
Quoted 8 lines
My suggestion is as follows:
Instead of
SDRAM_BASE, we can have new board specific configCONFIG_RISCV_PRIOR_FDT_BASEIf
CONFIG_RISCV_PRIOR_FDT_BASEis defined/selected by config then instart.Scopy-over the FDT from location pointed by "a1" register to location pointed byCONFIG_RISCV_PRIOR_FDT_BASE.Hi Anup
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
It can not achieve dtb delivery at runtime.
Can you elaborate why?
CONFIG_RISCV_PRIOR_FDT_BASEis determined at compile time. I am wondering how it can be modified at run time ?
I think you miss-understood my suggestion. I did not meant changing CONFIG_RISCV_PRIOR_FDT_BASE at runtime.
Quoted 5 lines
Quoted 3 lines
I am sure we can always relocate FDT passed by previous stage to some safer location and use it from there.
My original patch also can achieve that dtb passed by a1 and relocated and boot.
Great !!!
Why not update your original patch to relocate FDT and use FDT from safer location?
My intention is to have these two lines removed from start.S so that U-Boot S-mode
works fine on QEMU.
Regards,
Anup
PATCH v5 4/4 riscv: Remove redundant a2 store on DRAM base in start.S
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午2:40寫道:
Quoted 133 lines · Rick Chen
Quoted 117 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午2:14寫道:
Quoted 115 lines · On Tue, 27 Nov, 2018, 11:38 AM Rick Chen <[email protected] wrote:
Quoted 111 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午1:47寫道:
Quoted 97 lines · Anup Patel
Quoted 95 lines · Rick Chen
Quoted 84 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 上午11:28寫道:
Quoted 47 lines · Rick Chen
Quoted 45 lines
Quoted 33 lines
Quoted 32 lines
Quoted 32 lines
Quoted 27 lines
Currently, the RISC-V U-Boot is saving a2 register at
CONFIG_SYS_DRAM_BASE in start.S which does not make sense because
there is no information passed by previous booting stage in a2
register.This patch removes redundant a2 store on DRAM base.
Signed-off-by: Anup Patel <[email protected]>
---
arch/riscv/cpu/start.S | 2 --
1 file changed, 2 deletions(-)diff --git a/arch/riscv/cpu/start.S b/arch/riscv/cpu/start.S index
704190f946..e4276e8e19 100644
--- a/arch/riscv/cpu/start.S
+++ b/arch/riscv/cpu/start.S
@@ -38,8 +38,6 @@ _start:
mv s0, a0
mv s1, a1- li t0, CONFIG_SYS_SDRAM_BASE
- SREG a2, 0(t0)
la t0, trap_entry
#ifdef CONFIG_RISCV_SMODE
csrw stvec, t0
--This is weird. I remember these two lines were already removed by Lukas's patch series before? Did not have time to dig out the history though.
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Regards,
BinYou are correct, however I removed it again, because I did not want to break Rick's board. He did add a commit to the last pull request that removes these two lines and adjusts his board accordingly, but it is not in the current one.
Hi Likas
Thanks for your explanation.
Quoted 8 lines
Quoted 2 lines
RIck's commit as below
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlWhen we run U-Boot in S-mode the BBL runs from
0x80000000so this two lines corrupts BBL instructions.If this is important for some board then please have it around #ifdef.
Hi Anup
In the discussion as below :
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlI try to solve this issue with the aptch
[PATCH] riscv: ax25-ae350: Pass dtb address to u-boot with a1 registerarch/riscv/cpu/start.S +0
-2- li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0)board/AndesTech/ax25-ae350/ax25-ae350.c +1
-1void *board_fdt_blob_setup (void ) { -void **ptr = (void *)CONFIG_SYS_SDRAM_BASE ; +void **ptr = (void *)&prior_stage_fdt_address;in the previous pull request.
But Bin do not agree with that I use
prior_stage_fdt_addressinboard_fdt_blob_setup( )
I try to explain why I use it like that way.
Then Bin have not any reply in the following mail. Finally I decide to drop this patch in the next pull request.Quoted 3 lines
Hi Bin
How do you think about I recovery this patch to fix this issue ?
Actually, previous booting stage can pass location of FDT stored in flash to U-Boot. U-Boot requires FDT at a DRAM location which it can modify in-place before passing on to Linux kernel so we should relocate the FDT passed by previous booting stage to some board specific DRAM location.
Quoted 9 lines
Quoted 8 lines
My suggestion is as follows:
Instead of
SDRAM_BASE, we can have new board specific configCONFIG_RISCV_PRIOR_FDT_BASEIf
CONFIG_RISCV_PRIOR_FDT_BASEis defined/selected by config then instart.Scopy-over the FDT from location pointed by "a1" register to location pointed byCONFIG_RISCV_PRIOR_FDT_BASE.Hi Anup
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
It can not achieve dtb delivery at runtime.
Can you elaborate why?
CONFIG_RISCV_PRIOR_FDT_BASEis determined at compile time. I am wondering how it can be modified at run time ?I think you miss-understood my suggestion. I did not meant changing
CONFIG_RISCV_PRIOR_FDT_BASEat runtime.Quoted 2 lines
Quoted 9 lines
Quoted 3 lines
Quoted 1 line
I am sure we can always relocate FDT passed by previous stage to some safer location and use it from there.
My original patch also can achieve that dtb passed by a1 and relocated and boot.
Great !!!
Why not update your original patch to relocate FDT and use FDT from safer location?
Good question.
Above can see the question I ask for Bin :
How do you think about I recovery this patch to fix this issue ?
Before you talking about CONFIG_RISCV_PRIOR_FDT_BASE !
Quoted 6 lines
My intention is to have these two lines removed from
start.Sso that U-Boot S-mode
works fine on QEMU.Regards,
Anup
PATCH v5 4/4 riscv: Remove redundant a2 store on DRAM base in start.S
Quoted 145 lines · Rick Chen
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午2:40寫道:
Quoted 133 lines · Rick Chen
Quoted 117 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午2:14寫道:
Quoted 115 lines · On Tue, 27 Nov, 2018, 11:38 AM Rick Chen <[email protected] wrote:
Quoted 111 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午1:47寫道:
Quoted 97 lines · Anup Patel
Quoted 95 lines · Rick Chen
Quoted 84 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 上午11:28寫道:
Quoted 47 lines · Rick Chen
Quoted 45 lines
Quoted 33 lines
Quoted 32 lines
Quoted 32 lines
Currently, the RISC-V U-Boot is saving a2 register at
CONFIG_SYS_DRAM_BASE in start.S which does not make sense because
there is no information passed by previous booting stage in a2
register.This patch removes redundant a2 store on DRAM base.
Signed-off-by: Anup Patel <[email protected]>
---
arch/riscv/cpu/start.S | 2 --
1 file changed, 2 deletions(-)diff --git a/arch/riscv/cpu/start.S b/arch/riscv/cpu/start.S index
704190f946..e4276e8e19 100644
--- a/arch/riscv/cpu/start.S
+++ b/arch/riscv/cpu/start.S
@@ -38,8 +38,6 @@ _start:
mv s0, a0
mv s1, a1- li t0, CONFIG_SYS_SDRAM_BASE
- SREG a2, 0(t0)
la t0, trap_entry
#ifdef CONFIG_RISCV_SMODE
csrw stvec, t0
--This is weird. I remember these two lines were already removed by
Lukas's patch series before? Did not have time to dig out the history
though.Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Regards,
BinYou are correct, however I removed it again, because I did not want to break Rick's board. He did add a commit to the last pull request that removes these two lines and adjusts his board accordingly, but it is not in the current one.
Hi Likas
Thanks for your explanation.
Quoted 8 lines
Quoted 2 lines
RIck's commit as below
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlWhen we run U-Boot in S-mode the BBL runs from
0x80000000so this two lines corrupts BBL instructions.If this is important for some board then please have it around #ifdef.
Hi Anup
In the discussion as below :
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlI try to solve this issue with the aptch
[PATCH] riscv: ax25-ae350: Pass dtb address to u-boot with a1 registerarch/riscv/cpu/start.S +0
-2- li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0)board/AndesTech/ax25-ae350/ax25-ae350.c +1
-1void *board_fdt_blob_setup (void ) { -void **ptr = (void *)CONFIG_SYS_SDRAM_BASE ; +void **ptr = (void *)&prior_stage_fdt_address;in the previous pull request.
But Bin do not agree with that I use
prior_stage_fdt_addressinboard_fdt_blob_setup( )
I try to explain why I use it like that way.
Then Bin have not any reply in the following mail. Finally I decide to drop this patch in the next pull request.Quoted 3 lines
Hi Bin
How do you think about I recovery this patch to fix this issue ?
Actually, previous booting stage can pass location of FDT stored in flash to U-Boot. U-Boot requires FDT at a DRAM location which it can modify in-place before passing on to Linux kernel so we should relocate the FDT passed by previous booting stage to some board specific DRAM location.
Quoted 9 lines
Quoted 8 lines
My suggestion is as follows:
Instead of
SDRAM_BASE, we can have new board specific configCONFIG_RISCV_PRIOR_FDT_BASEIf
CONFIG_RISCV_PRIOR_FDT_BASEis defined/selected by config then instart.Scopy-over the FDT from location pointed by "a1" register to location pointed byCONFIG_RISCV_PRIOR_FDT_BASE.Hi Anup
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
It can not achieve dtb delivery at runtime.
Can you elaborate why?
CONFIG_RISCV_PRIOR_FDT_BASEis determined at compile time. I am wondering how it can be modified at run time ?I think you miss-understood my suggestion. I did not meant changing
CONFIG_RISCV_PRIOR_FDT_BASEat runtime.Quoted 2 lines
Quoted 9 lines
Quoted 3 lines
Quoted 1 line
I am sure we can always relocate FDT passed by previous stage to some safer location and use it from there.
My original patch also can achieve that dtb passed by a1 and relocated and boot.
Great !!!
Why not update your original patch to relocate FDT and use FDT from safer location?
Quoted 5 lines
Good question.
Above can see the question I ask for Bin :
How do you think about I recovery this patch to fix this issue ?Before you talking about
CONFIG_RISCV_PRIOR_FDT_BASE!
Can you explain why you need CONFIG_OF_BOARD ?
Why can you not use CONFIG_OF_PRIOR_STAGE ?
Regards,
Anup
PATCH v5 4/4 riscv: Remove redundant a2 store on DRAM base in start.S
Quoted 147 lines · Anup Patel
Quoted 145 lines · Rick Chen
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午2:40寫道:
Quoted 142 lines · Rick Chen
Quoted 117 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午2:14寫道:
Quoted 115 lines · On Tue, 27 Nov, 2018, 11:38 AM Rick Chen <[email protected] wrote:
Quoted 111 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午1:47寫道:
Quoted 97 lines · Anup Patel
Quoted 95 lines · Rick Chen
Quoted 84 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 上午11:28寫道:
Quoted 47 lines · Rick Chen
Quoted 45 lines
Quoted 33 lines
Quoted 32 lines
Currently, the RISC-V U-Boot is saving a2 register at
CONFIG_SYS_DRAM_BASE in start.S which does not make sense because
there is no information passed by previous booting stage in a2
register.This patch removes redundant a2 store on DRAM base.
Signed-off-by: Anup Patel <[email protected]>
---
arch/riscv/cpu/start.S | 2 --
1 file changed, 2 deletions(-)diff --git a/arch/riscv/cpu/start.S b/arch/riscv/cpu/start.S index
704190f946..e4276e8e19 100644
--- a/arch/riscv/cpu/start.S
+++ b/arch/riscv/cpu/start.S
@@ -38,8 +38,6 @@ _start:
mv s0, a0
mv s1, a1- li t0, CONFIG_SYS_SDRAM_BASE
- SREG a2, 0(t0)
la t0, trap_entry
#ifdef CONFIG_RISCV_SMODE
csrw stvec, t0
--This is weird. I remember these two lines were already removed by
Lukas's patch series before? Did not have time to dig out the history
though.Quoted 7 lines
Quoted 7 lines
Regards,
BinYou are correct, however I removed it again, because I did not want to break
Rick's board. He did add a commit to the last pull request that removes these
two lines and adjusts his board accordingly, but it is not in the current one.Hi Likas
Thanks for your explanation.
Quoted 8 lines
Quoted 2 lines
RIck's commit as below
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlWhen we run U-Boot in S-mode the BBL runs from
0x80000000so this two lines corrupts BBL instructions.If this is important for some board then please have it around #ifdef.
Hi Anup
In the discussion as below :
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlI try to solve this issue with the aptch
[PATCH] riscv: ax25-ae350: Pass dtb address to u-boot with a1 registerarch/riscv/cpu/start.S +0
-2- li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0)board/AndesTech/ax25-ae350/ax25-ae350.c +1
-1void *board_fdt_blob_setup (void ) { -void **ptr = (void *)CONFIG_SYS_SDRAM_BASE ; +void **ptr = (void *)&prior_stage_fdt_address;in the previous pull request.
But Bin do not agree with that I use
prior_stage_fdt_addressinboard_fdt_blob_setup( )
I try to explain why I use it like that way.
Then Bin have not any reply in the following mail. Finally I decide to drop this patch in the next pull request.Quoted 3 lines
Hi Bin
How do you think about I recovery this patch to fix this issue ?
Actually, previous booting stage can pass location of FDT stored in flash to U-Boot. U-Boot requires FDT at a DRAM location which it can modify in-place before passing on to Linux kernel so we should relocate the FDT passed by previous booting stage to some board specific DRAM location.
Quoted 9 lines
Quoted 8 lines
My suggestion is as follows:
Instead of
SDRAM_BASE, we can have new board specific configCONFIG_RISCV_PRIOR_FDT_BASEIf
CONFIG_RISCV_PRIOR_FDT_BASEis defined/selected by config then instart.Scopy-over the FDT from location pointed by "a1" register to location pointed byCONFIG_RISCV_PRIOR_FDT_BASE.Hi Anup
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
It can not achieve dtb delivery at runtime.
Can you elaborate why?
CONFIG_RISCV_PRIOR_FDT_BASEis determined at compile time. I am wondering how it can be modified at run time ?I think you miss-understood my suggestion. I did not meant changing
CONFIG_RISCV_PRIOR_FDT_BASEat runtime.Quoted 5 lines
Quoted 3 lines
I am sure we can always relocate FDT passed by previous stage to some safer location and use it from there.
My original patch also can achieve that dtb passed by a1 and relocated and boot.
Great !!!
Why not update your original patch to relocate FDT and use FDT from safer location?
Quoted 8 lines
Quoted 5 lines
Good question.
Above can see the question I ask for Bin :
How do you think about I recovery this patch to fix this issue ?Before you talking about
CONFIG_RISCV_PRIOR_FDT_BASE!Can you explain why you need
CONFIG_OF_BOARD?
Why can you not useCONFIG_OF_PRIOR_STAGE?
I think I got your problem with CONFIG_OF_PRIOR_STAGE. U-Boot cannot update prior_stage_fdt_address when running from ROM/Flash.
Instead of storing FDT pointer on CONFIG_SYS_SDRAM_BASE, you can have a board specific location to save FDT pointer when booting from flash.
Here's a simple reference implementation (untested):
arch/riscv/Kconfig +13 -0
@@ -60,6 +60,19 @@ config RISCV_SMODE help Enable this option to build U-Boot for RISC-V S-Mode +config RISCV_FDTPTR_SAVE + bool "Save FDT pointer for flash booting" + help + Enable this option to save FDT pointer passed to U-Boot + booting from ROM or Flash. + +config RISCV_FDTPTR_SAVE_ADDR + hex "Location for saving FDT pointer" + depends on RISCV_FDTPTR_SAVE + help + Set this to provide board specific location for saving + FDT pointer. + config 32BIT bool
arch/riscv/cpu/start.S +5 -0
@@ -38,6 +38,11 @@ _start: mv s0, a0 mv s1, a1 +#ifdef CONFIG_RISCV_FDTPTR_SAVE + li t0, CONFIG_RISCV_FDTPTR_SAVE_ADDR + SREG s1, 0(t0) +#endif + la t0, trap_entry #ifdef CONFIG_RISCV_SMODE csrw stvec, t0
(quoted diff) +0 -0
b/board/AndesTech/ax25-ae350/ax25-ae350.c
index 5f4ca0f5a7..f3535a1d52 100644
board/AndesTech/ax25-ae350/ax25-ae350.c +0 -0
@@ -66,9 +66,9 @@ ulong board_flash_get_legacy(ulong base, int
banknum, flash_info_t *info)
void *board_fdt_blob_setup(void)
{
- void **ptr = (void *)CONFIG_SYS_SDRAM_BASE;
+ void **ptr = (void *)CONFIG_RISCV_FDTPTR_SAVE_ADDR; if (fdt_magic(*ptr) == FDT_MAGIC)
- return (void *)*ptr;
+ return (void *)*ptr;
return (void *)CONFIG_SYS_FDT_BASE;
}
configs/ax25-ae350_64_defconfig +2 -0
@@ -35,3 +35,5 @@ CONFIG_SYS_NS16550=y CONFIG_SPI=y CONFIG_ATCSPI200_SPI=y CONFIG_ATCPIT100_TIMER=y +CONFIG_RISCV_FDTPTR_SAVE=y +CONFIG_RISCV_FDTPTR_SAVE_ADDR=0x80000000
Regards,
Anup
PATCH v5 4/4 riscv: Remove redundant a2 store on DRAM base in start.S
Quoted 157 lines · Anup Patel
Quoted 147 lines · Anup Patel
Quoted 145 lines · Rick Chen
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午2:40寫道:
Quoted 142 lines · Rick Chen
Quoted 117 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午2:14寫道:
Quoted 115 lines · On Tue, 27 Nov, 2018, 11:38 AM Rick Chen <[email protected] wrote:
Quoted 111 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午1:47寫道:
Quoted 97 lines · Anup Patel
Quoted 95 lines · Rick Chen
Quoted 84 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 上午11:28寫道:
Quoted 47 lines · Rick Chen
Quoted 45 lines
Quoted 40 lines
Currently, the RISC-V U-Boot is saving a2 register at
CONFIG_SYS_DRAM_BASE in start.S which does not make sense because
there is no information passed by previous booting stage in a2
register.This patch removes redundant a2 store on DRAM base.
Signed-off-by: Anup Patel <[email protected]>
---
arch/riscv/cpu/start.S | 2 --
1 file changed, 2 deletions(-)diff --git a/arch/riscv/cpu/start.S b/arch/riscv/cpu/start.S index
704190f946..e4276e8e19 100644
--- a/arch/riscv/cpu/start.S
+++ b/arch/riscv/cpu/start.S
@@ -38,8 +38,6 @@ _start:
mv s0, a0
mv s1, a1- li t0, CONFIG_SYS_SDRAM_BASE
- SREG a2, 0(t0)
la t0, trap_entry
#ifdef CONFIG_RISCV_SMODE
csrw stvec, t0
--This is weird. I remember these two lines were already removed by
Lukas's patch series before? Did not have time to dig out the history
though.Regards,
BinYou are correct, however I removed it again, because I did not want to break
Rick's board. He did add a commit to the last pull request that removes these
two lines and adjusts his board accordingly, but it is not in the current one.Hi Likas
Thanks for your explanation.
Quoted 8 lines
Quoted 2 lines
RIck's commit as below
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlWhen we run U-Boot in S-mode the BBL runs from
0x80000000so this two lines corrupts BBL instructions.If this is important for some board then please have it around #ifdef.
Hi Anup
In the discussion as below :
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlI try to solve this issue with the aptch
[PATCH] riscv: ax25-ae350: Pass dtb address to u-boot with a1 registerarch/riscv/cpu/start.S +0
-2- li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0)board/AndesTech/ax25-ae350/ax25-ae350.c +1
-1void *board_fdt_blob_setup (void ) { -void **ptr = (void *)CONFIG_SYS_SDRAM_BASE ; +void **ptr = (void *)&prior_stage_fdt_address;in the previous pull request.
But Bin do not agree with that I use
prior_stage_fdt_addressinboard_fdt_blob_setup( )
I try to explain why I use it like that way.
Then Bin have not any reply in the following mail. Finally I decide to drop this patch in the next pull request.Quoted 3 lines
Hi Bin
How do you think about I recovery this patch to fix this issue ?
Actually, previous booting stage can pass location of FDT stored in flash to U-Boot. U-Boot requires FDT at a DRAM location which it can modify in-place before passing on to Linux kernel so we should relocate the FDT passed by previous booting stage to some board specific DRAM location.
Quoted 9 lines
Quoted 8 lines
My suggestion is as follows:
Instead of
SDRAM_BASE, we can have new board specific configCONFIG_RISCV_PRIOR_FDT_BASEIf
CONFIG_RISCV_PRIOR_FDT_BASEis defined/selected by config then instart.Scopy-over the FDT from location pointed by "a1" register to location pointed byCONFIG_RISCV_PRIOR_FDT_BASE.Hi Anup
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
It can not achieve dtb delivery at runtime.
Can you elaborate why?
CONFIG_RISCV_PRIOR_FDT_BASEis determined at compile time. I am wondering how it can be modified at run time ?I think you miss-understood my suggestion. I did not meant changing
CONFIG_RISCV_PRIOR_FDT_BASEat runtime.Quoted 5 lines
Quoted 3 lines
I am sure we can always relocate FDT passed by previous stage to some safer location and use it from there.
My original patch also can achieve that dtb passed by a1 and relocated and boot.
Great !!!
Why not update your original patch to relocate FDT and use FDT from safer location?
Quoted 8 lines
Quoted 5 lines
Good question.
Above can see the question I ask for Bin :
How do you think about I recovery this patch to fix this issue ?Before you talking about
CONFIG_RISCV_PRIOR_FDT_BASE!Can you explain why you need
CONFIG_OF_BOARD?
Why can you not useCONFIG_OF_PRIOR_STAGE?
Quoted 6 lines
I think I got your problem with
CONFIG_OF_PRIOR_STAGE. U-Boot cannot updateprior_stage_fdt_addresswhen running from ROM/Flash.Instead of storing FDT pointer on
CONFIG_SYS_SDRAM_BASE, you can have a board specific location to save FDT pointer when booting from flash.
I feel like I'm missing something obvious here. Why can't we just preserve a2 in a callee saved register and then eventually write it straight into gd?
For example, how about something like this (untested, probably mangled by mailer):
arch/riscv/cpu/cpu.c +5 -0
@@ -47,3 +47,8 @@ int print_cpuinfo(void)return 0 ; } + +void arch_setup_gd (gd_t *new_gd,ulong arg) +{ + new_gd->fdt_blob = (const void *)arg; +}
arch/riscv/cpu/start.S +2 -2
@@ -44,8 +44,7 @@ trap_vector: .global trap_entry handle_reset: - li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0) + mv s0, a2 la t0, trap_entry csrw mtvec, t0 csrwi mstatus, 0
@@ -75,6 +74,7 @@ call_board_init_f_0: mv a0, sp jal board_init_f_alloc_reserve mv sp, a0 + mv a1, s0 jal board_init_f_init_reserve mv a0, zero /* a0 <-- boot_flags = 0 */
arch/x86/cpu/i386/cpu.c +0 -0
@@ -113,7 +113,7 @@ static void load_gdt(const u64 *boot_gdt, u16
num_entries)
asm volatile("lgdtl %0\n" : : "m" (gdt));
}
-void arch_setup_gd(gd_t *new_gd)
+void arch_setup_gd(gd_t *new_gd, ulong arg)
{
u64 *gdt_addr;
arch/x86/cpu/x86_64/cpu.c +1 -1
@@ -16,7 +16,7 @@*/ struct global_data *global_data_ptr = (struct global_data *)~0 ; -void arch_setup_gd (gd_t *new_gd) +void arch_setup_gd (gd_t *new_gd,ulong arg) { global_data_ptr = new_gd; }
arch/x86/lib/spl.c +1 -1
@@ -72,7 +72,7 @@ static int x86_spl_init(void)*/ gd->new_gd = (struct global_data *)ptr;memcpy (gd->new_gd, gd,sizeof (*gd)); -arch_setup_gd (gd->new_gd); +arch_setup_gd (gd->new_gd,0 ); gd->start_addr_sp = (ulong )ptr;/* Cache the SPI flash. Otherwise copying the code to RAM takes ages */
(quoted diff) +0 -0
b/board/AndesTech/ax25-ae350/ax25-ae350.c
index 5f4ca0f5a7..74f2d40ec5 100644
board/AndesTech/ax25-ae350/ax25-ae350.c +0 -0
@@ -66,9 +66,8 @@ ulong board_flash_get_legacy(ulong base, int banknum,
flash_info_t *info)
void *board_fdt_blob_setup(void)
{
- void **ptr = (void *)CONFIG_SYS_SDRAM_BASE;
- if (fdt_magic(*ptr) == FDT_MAGIC)
- return (void *)*ptr;
+ if (fdt_magic(gd->fdt_blob) == FDT_MAGIC)
+ return (void *)gd->fdt_blob;
return (void *)CONFIG_SYS_FDT_BASE;
}
common/board_f.c +1 -1
@@ -726,7 +726,7 @@ static int jump_to_copy(void)* with the stack in SDRAM and Global Data in temporary memory * (CPU cache) */ -arch_setup_gd (gd->new_gd); +arch_setup_gd (gd->new_gd,0 );board_init_f_r_trampoline (gd->start_addr_sp);#else relocate_code (gd->start_addr_sp, gd->new_gd, gd->relocaddr);
common/board_r.c +1 -1
@@ -856,7 +856,7 @@ void board_init_r(gd_t *new_gd, ulong dest_addr)* dropping the new_gd parameter. */ #if CONFIG_IS_ENABLED (X86_64 ) -arch_setup_gd (new_gd); +arch_setup_gd (new_gd,0 );#endif #ifdef CONFIG_NEEDS_MANUAL_RELOC
common/init/board_init.c +0 -0
@@ -12,7 +12,7 @@ DECLARE_GLOBAL_DATA_PTR;/* Unfortunately x86 or ARM can't compile this code as gd cannot be
assigned */
#if !defined(CONFIG_X86) && !defined(CONFIG_ARM)
-__weak void arch_setup_gd(struct global_data *gd_ptr) +__weak void arch_setup_gd(struct global_data *gd_ptr, ulong arg)
{
gd = gd_ptr;
}
@@ -96,7 +96,7 @@ ulong board_init_f_alloc_reserve(ulong top)
* (seemingly useless) incrementation causes no code increase. */
-void board_init_f_init_reserve(ulong base) +void board_init_f_init_reserve(ulong base, ulong arg)
{
struct global_data *gd_ptr;
@@ -110,7 +110,7 @@ void board_init_f_init_reserve(ulong base)
memset(gd_ptr, '\0', sizeof(*gd));
/* set GD unless architecture did it already */
#if !defined(CONFIG_ARM)
- arch_setup_gd(gd_ptr);
+ arch_setup_gd(gd_ptr, arg);
#endif
/* next alloc will be higher by one GD plus 16-byte alignment */ base += roundup(sizeof(struct global_data), 16);
include/init.h +1 -0
@@ -152,6 +152,7 @@ void board_init_f_init_reserve(ulong base);/** * arch_setup_gd() - Set up the global_data pointer * @gd_ptr: Pointer to global data +* @arg: Architecture specific opaque data * * This pointer is special in some architectures and cannot easily be
assigned
* to. For example on x86 it is implemented by adding a specific record
to its
@@ -160,7 +161,7 @@ void board_init_f_init_reserve(ulong base);
*
* gd = gd_ptr;
*/
-void arch_setup_gd(gd_t *gd_ptr);
+void arch_setup_gd(gd_t *gd_ptr, ulong arg);
/* common/board_r.c */
void board_init_r(gd_t *id, ulong dest_addr) __attribute__ ((noreturn));
PATCH v5 4/4 riscv: Remove redundant a2 store on DRAM base in start.S
Alexander Graf <[email protected]> 於 2018年11月27日 週二 下午6:42寫道:
Quoted 342 lines · Anup Patel
Quoted 157 lines · Anup Patel
Quoted 147 lines · Rick Chen
Quoted 145 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午2:40寫道:
Quoted 142 lines · Rick Chen
Quoted 117 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午2:14寫道:
Quoted 115 lines · On Tue, 27 Nov, 2018, 11:38 AM Rick Chen <[email protected] wrote:
Quoted 111 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午1:47寫道:
Quoted 97 lines · Anup Patel
Quoted 95 lines · Rick Chen
Quoted 84 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 上午11:28寫道:
Quoted 47 lines · Rick Chen
Quoted 45 lines
Currently, the RISC-V U-Boot is saving a2 register at
CONFIG_SYS_DRAM_BASE in start.S which does not make sense because
there is no information passed by previous booting stage in a2
register.This patch removes redundant a2 store on DRAM base.
Signed-off-by: Anup Patel <[email protected]>
---
arch/riscv/cpu/start.S | 2 --
1 file changed, 2 deletions(-)diff --git a/arch/riscv/cpu/start.S b/arch/riscv/cpu/start.S index
704190f946..e4276e8e19 100644
--- a/arch/riscv/cpu/start.S
+++ b/arch/riscv/cpu/start.S
@@ -38,8 +38,6 @@ _start:
mv s0, a0
mv s1, a1- li t0, CONFIG_SYS_SDRAM_BASE
- SREG a2, 0(t0)
la t0, trap_entry
#ifdef CONFIG_RISCV_SMODE
csrw stvec, t0
--This is weird. I remember these two lines were already removed by
Lukas's patch series before? Did not have time to dig out the history
though.Regards,
BinYou are correct, however I removed it again, because I did not want to break
Rick's board. He did add a commit to the last pull request that removes these
two lines and adjusts his board accordingly, but it is not in the current one.Hi Likas
Thanks for your explanation.
Quoted 8 lines
Quoted 2 lines
RIck's commit as below
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlWhen we run U-Boot in S-mode the BBL runs from
0x80000000so this two lines corrupts BBL instructions.If this is important for some board then please have it around #ifdef.
Hi Anup
In the discussion as below :
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlI try to solve this issue with the aptch
[PATCH] riscv: ax25-ae350: Pass dtb address to u-boot with a1 registerarch/riscv/cpu/start.S +0
-2- li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0)board/AndesTech/ax25-ae350/ax25-ae350.c +1
-1void *board_fdt_blob_setup (void ) { -void **ptr = (void *)CONFIG_SYS_SDRAM_BASE ; +void **ptr = (void *)&prior_stage_fdt_address;in the previous pull request.
But Bin do not agree with that I use
prior_stage_fdt_addressinboard_fdt_blob_setup( )
I try to explain why I use it like that way.
Then Bin have not any reply in the following mail. Finally I decide to drop this patch in the next pull request.Quoted 3 lines
Hi Bin
How do you think about I recovery this patch to fix this issue ?
Actually, previous booting stage can pass location of FDT stored in flash to U-Boot. U-Boot requires FDT at a DRAM location which it can modify in-place before passing on to Linux kernel so we should relocate the FDT passed by previous booting stage to some board specific DRAM location.
Quoted 9 lines
Quoted 8 lines
My suggestion is as follows:
Instead of
SDRAM_BASE, we can have new board specific configCONFIG_RISCV_PRIOR_FDT_BASEIf
CONFIG_RISCV_PRIOR_FDT_BASEis defined/selected by config then instart.Scopy-over the FDT from location pointed by "a1" register to location pointed byCONFIG_RISCV_PRIOR_FDT_BASE.Hi Anup
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
It can not achieve dtb delivery at runtime.
Can you elaborate why?
CONFIG_RISCV_PRIOR_FDT_BASEis determined at compile time. I am wondering how it can be modified at run time ?I think you miss-understood my suggestion. I did not meant changing
CONFIG_RISCV_PRIOR_FDT_BASEat runtime.Quoted 5 lines
Quoted 3 lines
I am sure we can always relocate FDT passed by previous stage to some safer location and use it from there.
My original patch also can achieve that dtb passed by a1 and relocated and boot.
Great !!!
Why not update your original patch to relocate FDT and use FDT from safer location?
Quoted 8 lines
Quoted 5 lines
Good question.
Above can see the question I ask for Bin :
How do you think about I recovery this patch to fix this issue ?Before you talking about
CONFIG_RISCV_PRIOR_FDT_BASE!Can you explain why you need
CONFIG_OF_BOARD?
Why can you not useCONFIG_OF_PRIOR_STAGE?Quoted 6 lines
I think I got your problem with
CONFIG_OF_PRIOR_STAGE. U-Boot cannot updateprior_stage_fdt_addresswhen running from ROM/Flash.Instead of storing FDT pointer on
CONFIG_SYS_SDRAM_BASE, you can have a board specific location to save FDT pointer when booting from flash.I feel like I'm missing something obvious here. Why can't we just preserve a2 in a callee saved register and then eventually write it straight into gd?
For example, how about something like this (untested, probably mangled by mailer):
arch/riscv/cpu/cpu.c +5
-0@@ -47,3 +47,8 @@ int print_cpuinfo(void)return 0 ; } + +void arch_setup_gd (gd_t *new_gd,ulong arg) +{ + new_gd->fdt_blob = (const void *)arg; +}arch/riscv/cpu/start.S +2
-2@@ -44,8 +44,7 @@ trap_vector: .global trap_entry handle_reset: - li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0) + mv s0, a2 la t0, trap_entry csrw mtvec, t0 csrwi mstatus, 0@@ -75,6 +74,7 @@ call_board_init_f_0: mv a0, sp jal board_init_f_alloc_reserve mv sp, a0 + mv a1, s0 jal board_init_f_init_reserve mv a0, zero /* a0 <-- boot_flags = 0 */arch/x86/cpu/i386/cpu.c +1
-1@@ -113,7 +113,7 @@ static void load_gdt(const u64 *boot_gdt, u16 num_entries) asmvolatile ("lgdtl %0\n" : :"m" (gdt)); } -void arch_setup_gd (gd_t *new_gd) +void arch_setup_gd (gd_t *new_gd,ulong arg) {u64 *gdt_addr;arch/x86/cpu/x86_64/cpu.c +1
-1@@ -16,7 +16,7 @@*/ struct global_data *global_data_ptr = (struct global_data *)~0 ; -void arch_setup_gd (gd_t *new_gd) +void arch_setup_gd (gd_t *new_gd,ulong arg) { global_data_ptr = new_gd; }arch/x86/lib/spl.c +1
-1@@ -72,7 +72,7 @@ static int x86_spl_init(void)*/ gd->new_gd = (struct global_data *)ptr;memcpy (gd->new_gd, gd,sizeof (*gd)); -arch_setup_gd (gd->new_gd); +arch_setup_gd (gd->new_gd,0 ); gd->start_addr_sp = (ulong )ptr;/* Cache the SPI flash. Otherwise copying the code to RAM takes ages */ board/AndesTech/ax25-ae350/ax25-ae350.c +2
-3@@ -66,9 +66,8 @@ ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t *info)void *board_fdt_blob_setup (void ) { -void **ptr = (void *)CONFIG_SYS_SDRAM_BASE ; -if (fdt_magic (*ptr) ==FDT_MAGIC ) -return (void *)*ptr; +if (fdt_magic (gd->fdt_blob) ==FDT_MAGIC ) +return (void *)gd->fdt_blob;return (void *)CONFIG_SYS_FDT_BASE ;}
common/board_f.c +1
-1@@ -726,7 +726,7 @@ static int jump_to_copy(void)* with the stack in SDRAM and Global Data in temporary memory * (CPU cache) */ -arch_setup_gd (gd->new_gd); +arch_setup_gd (gd->new_gd,0 );board_init_f_r_trampoline (gd->start_addr_sp);#else relocate_code (gd->start_addr_sp, gd->new_gd, gd->relocaddr);common/board_r.c +1
-1@@ -856,7 +856,7 @@ void board_init_r(gd_t *new_gd, ulong dest_addr)* dropping the new_gd parameter. */ #if CONFIG_IS_ENABLED (X86_64 ) -arch_setup_gd (new_gd); +arch_setup_gd (new_gd,0 );#endif #ifdef CONFIG_NEEDS_MANUAL_RELOC common/init/board_init.c +0
-0@@ -12,7 +12,7 @@ DECLARE_GLOBAL_DATA_PTR;/* Unfortunately x86 or ARM can't compile this code as gd cannot be assigned */
#if !defined(CONFIG_X86) && !defined(CONFIG_ARM)common/init/board_init.c +3
-3-__weak void arch_setup_gd (struct global_data *gd_ptr) +__weak void arch_setup_gd (struct global_data *gd_ptr,ulong arg) { gd = gd_ptr; }@@ -96,7 +96,7 @@ ulong board_init_f_alloc_reserve(ulong top)* (seemingly useless) incrementation causes no code increase. */ -void board_init_f_init_reserve (ulong base) +void board_init_f_init_reserve (ulong base,ulong arg) {struct global_data *gd_ptr;@@ -110,7 +110,7 @@ void board_init_f_init_reserve(ulong base)memset (gd_ptr,'\0' ,sizeof (*gd));/* set GD unless architecture did it already */ #if !defined(CONFIG_ARM ) -arch_setup_gd (gd_ptr); +arch_setup_gd (gd_ptr, arg);#endif /* next alloc will be higher by one GD plus 16-byte alignment */ base +=roundup (sizeof (struct global_data ),16 );include/init.h +1
-0@@ -152,6 +152,7 @@ void board_init_f_init_reserve(ulong base);/** * arch_setup_gd() - Set up the global_data pointer * @gd_ptr: Pointer to global data +* @arg: Architecture specific opaque data * * This pointer is special in some architectures and cannot easily be assigned
* to. For example on x86 it is implemented by adding a specific record
to its
include/init.h void board_init_f_init_reserve(ulong base); · line 167
Quoted 8 lines
include/init.h +1
-1@@ -160,7 +161,7 @@ void board_init_f_init_reserve(ulong base);* * gd = gd_ptr; */ -void arch_setup_gd (gd_t *gd_ptr); +void arch_setup_gd (gd_t *gd_ptr,ulong arg);/* common/board_r.c */ void board_init_r (gd_t *id,ulong dest_addr) __attribute__ ((noreturn));
Hi Alex
I will try and test it.
Thanks a lot
B.R
Rick
PATCH v5 4/4 riscv: Remove redundant a2 store on DRAM base in start.S
In reply to Anup PatelAnup Patel <[email protected]> 於 2018年11月27日 週二 下午3:56寫道:
Quoted 147 lines · Rick Chen
Quoted 145 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午2:40寫道:
Quoted 142 lines · Rick Chen
Quoted 117 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午2:14寫道:
Quoted 115 lines · On Tue, 27 Nov, 2018, 11:38 AM Rick Chen <[email protected] wrote:
Quoted 111 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午1:47寫道:
Quoted 97 lines · Anup Patel
Quoted 95 lines · Rick Chen
Quoted 84 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 上午11:28寫道:
Quoted 47 lines · Rick Chen
Quoted 45 lines
Quoted 33 lines
Quoted 32 lines
Currently, the RISC-V U-Boot is saving a2 register at
CONFIG_SYS_DRAM_BASE in start.S which does not make sense because
there is no information passed by previous booting stage in a2
register.This patch removes redundant a2 store on DRAM base.
Signed-off-by: Anup Patel <[email protected]>
---
arch/riscv/cpu/start.S | 2 --
1 file changed, 2 deletions(-)diff --git a/arch/riscv/cpu/start.S b/arch/riscv/cpu/start.S index
704190f946..e4276e8e19 100644
--- a/arch/riscv/cpu/start.S
+++ b/arch/riscv/cpu/start.S
@@ -38,8 +38,6 @@ _start:
mv s0, a0
mv s1, a1- li t0, CONFIG_SYS_SDRAM_BASE
- SREG a2, 0(t0)
la t0, trap_entry
#ifdef CONFIG_RISCV_SMODE
csrw stvec, t0
--This is weird. I remember these two lines were already removed by
Lukas's patch series before? Did not have time to dig out the history
though.Quoted 7 lines
Quoted 7 lines
Regards,
BinYou are correct, however I removed it again, because I did not want to break
Rick's board. He did add a commit to the last pull request that removes these
two lines and adjusts his board accordingly, but it is not in the current one.Hi Likas
Thanks for your explanation.
Quoted 8 lines
Quoted 2 lines
RIck's commit as below
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlWhen we run U-Boot in S-mode the BBL runs from
0x80000000so this two lines corrupts BBL instructions.If this is important for some board then please have it around #ifdef.
Hi Anup
In the discussion as below :
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlI try to solve this issue with the aptch
[PATCH] riscv: ax25-ae350: Pass dtb address to u-boot with a1 registerarch/riscv/cpu/start.S +0
-2- li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0)board/AndesTech/ax25-ae350/ax25-ae350.c +1
-1void *board_fdt_blob_setup (void ) { -void **ptr = (void *)CONFIG_SYS_SDRAM_BASE ; +void **ptr = (void *)&prior_stage_fdt_address;in the previous pull request.
But Bin do not agree with that I use
prior_stage_fdt_addressinboard_fdt_blob_setup( )
I try to explain why I use it like that way.
Then Bin have not any reply in the following mail. Finally I decide to drop this patch in the next pull request.Quoted 3 lines
Hi Bin
How do you think about I recovery this patch to fix this issue ?
Actually, previous booting stage can pass location of FDT stored in flash to U-Boot. U-Boot requires FDT at a DRAM location which it can modify in-place before passing on to Linux kernel so we should relocate the FDT passed by previous booting stage to some board specific DRAM location.
Quoted 9 lines
Quoted 8 lines
My suggestion is as follows:
Instead of
SDRAM_BASE, we can have new board specific configCONFIG_RISCV_PRIOR_FDT_BASEIf
CONFIG_RISCV_PRIOR_FDT_BASEis defined/selected by config then instart.Scopy-over the FDT from location pointed by "a1" register to location pointed byCONFIG_RISCV_PRIOR_FDT_BASE.Hi Anup
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
It can not achieve dtb delivery at runtime.
Can you elaborate why?
CONFIG_RISCV_PRIOR_FDT_BASEis determined at compile time. I am wondering how it can be modified at run time ?I think you miss-understood my suggestion. I did not meant changing
CONFIG_RISCV_PRIOR_FDT_BASEat runtime.Quoted 5 lines
Quoted 3 lines
I am sure we can always relocate FDT passed by previous stage to some safer location and use it from there.
My original patch also can achieve that dtb passed by a1 and relocated and boot.
Great !!!
Why not update your original patch to relocate FDT and use FDT from safer location?
Quoted 9 lines
Quoted 5 lines
Good question.
Above can see the question I ask for Bin :
How do you think about I recovery this patch to fix this issue ?Before you talking about
CONFIG_RISCV_PRIOR_FDT_BASE!Can you explain why you need
CONFIG_OF_BOARD?
Why can you not useCONFIG_OF_PRIOR_STAGE?
You can find the discussion as below:
https://patchwork.ozlabs.org/patch/988884/
Quoted 2 lines
Regards,
Anup
PATCH v5 4/4 riscv: Remove redundant a2 store on DRAM base in start.S
Hi Rick,
Quoted 153 lines · Rick Chen
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午3:56寫道:
Quoted 151 lines · Rick Chen
Quoted 149 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午2:40寫道:
Quoted 133 lines · Rick Chen
Quoted 117 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午2:14寫道:
Quoted 115 lines · On Tue, 27 Nov, 2018, 11:38 AM Rick Chen <[email protected] wrote:
Quoted 111 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午1:47寫道:
Quoted 97 lines · Anup Patel
Quoted 95 lines · Rick Chen
Quoted 84 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 上午11:28寫道:
Quoted 47 lines · Rick Chen
Quoted 45 lines
Quoted 40 lines
Currently, the RISC-V U-Boot is saving a2 register at
CONFIG_SYS_DRAM_BASE in start.S which does not make sense because
there is no information passed by previous booting stage in a2
register.This patch removes redundant a2 store on DRAM base.
Signed-off-by: Anup Patel <[email protected]>
---
arch/riscv/cpu/start.S | 2 --
1 file changed, 2 deletions(-)diff --git a/arch/riscv/cpu/start.S b/arch/riscv/cpu/start.S index
704190f946..e4276e8e19 100644
--- a/arch/riscv/cpu/start.S
+++ b/arch/riscv/cpu/start.S
@@ -38,8 +38,6 @@ _start:
mv s0, a0
mv s1, a1- li t0, CONFIG_SYS_SDRAM_BASE
- SREG a2, 0(t0)
la t0, trap_entry
#ifdef CONFIG_RISCV_SMODE
csrw stvec, t0
--This is weird. I remember these two lines were already removed by
Lukas's patch series before? Did not have time to dig out the history
though.Regards,
BinYou are correct, however I removed it again, because I did not want to break
Rick's board. He did add a commit to the last pull request that removes these
two lines and adjusts his board accordingly, but it is not in the current one.Hi Likas
Thanks for your explanation.
Quoted 8 lines
Quoted 2 lines
RIck's commit as below
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlWhen we run U-Boot in S-mode the BBL runs from
0x80000000so this two lines corrupts BBL instructions.If this is important for some board then please have it around #ifdef.
Hi Anup
In the discussion as below :
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlI try to solve this issue with the aptch
[PATCH] riscv: ax25-ae350: Pass dtb address to u-boot with a1 registerarch/riscv/cpu/start.S +0
-2- li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0)board/AndesTech/ax25-ae350/ax25-ae350.c +1
-1void *board_fdt_blob_setup (void ) { -void **ptr = (void *)CONFIG_SYS_SDRAM_BASE ; +void **ptr = (void *)&prior_stage_fdt_address;in the previous pull request.
But Bin do not agree with that I use
prior_stage_fdt_addressinboard_fdt_blob_setup( )
I try to explain why I use it like that way.
Then Bin have not any reply in the following mail. Finally I decide to drop this patch in the next pull request.Quoted 3 lines
Hi Bin
How do you think about I recovery this patch to fix this issue ?
Actually, previous booting stage can pass location of FDT stored in flash to U-Boot. U-Boot requires FDT at a DRAM location which it can modify in-place before passing on to Linux kernel so we should relocate the FDT passed by previous booting stage to some board specific DRAM location.
Quoted 9 lines
Quoted 8 lines
My suggestion is as follows:
Instead of
SDRAM_BASE, we can have new board specific configCONFIG_RISCV_PRIOR_FDT_BASEIf
CONFIG_RISCV_PRIOR_FDT_BASEis defined/selected by config then instart.Scopy-over the FDT from location pointed by "a1" register to location pointed byCONFIG_RISCV_PRIOR_FDT_BASE.Hi Anup
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
It can not achieve dtb delivery at runtime.
Can you elaborate why?
CONFIG_RISCV_PRIOR_FDT_BASEis determined at compile time. I am wondering how it can be modified at run time ?I think you miss-understood my suggestion. I did not meant changing
CONFIG_RISCV_PRIOR_FDT_BASEat runtime.Quoted 2 lines
Quoted 9 lines
Quoted 3 lines
Quoted 1 line
I am sure we can always relocate FDT passed by previous stage to some safer location and use it from there.
My original patch also can achieve that dtb passed by a1 and relocated and boot.
Great !!!
Why not update your original patch to relocate FDT and use FDT from safer location?
Good question.
Above can see the question I ask for Bin :
How do you think about I recovery this patch to fix this issue ?
Quoted 9 lines
Quoted 5 lines
Quoted 1 line
Before you talking about
CONFIG_RISCV_PRIOR_FDT_BASE!Can you explain why you need
CONFIG_OF_BOARD?
Why can you not useCONFIG_OF_PRIOR_STAGE?You can find the discussion as below:
https://patchwork.ozlabs.org/patch/988884/
If I understand correctly, so far we have two scenarios to support:
1. U-Boot is booting directly from reset vector from ROM. This canonical way to support DT is via CONFIG_OF_EMBED or CONFIG_OF_SEPARATE. In such configuration, there is no any previous bootloader so the concept of CONFIG_OF_PRIOR_STAGE does not apply.
2. U-Boot is booting from previous bootloader, and DT is passed in a1 register. Such configuration we can use CONFIG_OF_PRIOR_STAGE.
Regards,
Bin
PATCH v5 4/4 riscv: Remove redundant a2 store on DRAM base in start.S
Bin Meng <[email protected]> 於 2018年11月27日 週二 下午6:07寫道:
Quoted 169 lines
Hi Rick,
Quoted 153 lines · Rick Chen
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午3:56寫道:
Quoted 151 lines · Rick Chen
Quoted 149 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午2:40寫道:
Quoted 133 lines · Rick Chen
Quoted 117 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午2:14寫道:
Quoted 115 lines · On Tue, 27 Nov, 2018, 11:38 AM Rick Chen <[email protected] wrote:
Quoted 111 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午1:47寫道:
Quoted 97 lines · Anup Patel
Quoted 95 lines · Rick Chen
Quoted 84 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 上午11:28寫道:
Quoted 47 lines · Rick Chen
Quoted 45 lines
Currently, the RISC-V U-Boot is saving a2 register at
CONFIG_SYS_DRAM_BASE in start.S which does not make sense because
there is no information passed by previous booting stage in a2
register.This patch removes redundant a2 store on DRAM base.
Signed-off-by: Anup Patel <[email protected]>
---
arch/riscv/cpu/start.S | 2 --
1 file changed, 2 deletions(-)diff --git a/arch/riscv/cpu/start.S b/arch/riscv/cpu/start.S index
704190f946..e4276e8e19 100644
--- a/arch/riscv/cpu/start.S
+++ b/arch/riscv/cpu/start.S
@@ -38,8 +38,6 @@ _start:
mv s0, a0
mv s1, a1- li t0, CONFIG_SYS_SDRAM_BASE
- SREG a2, 0(t0)
la t0, trap_entry
#ifdef CONFIG_RISCV_SMODE
csrw stvec, t0
--This is weird. I remember these two lines were already removed by
Lukas's patch series before? Did not have time to dig out the history
though.Regards,
BinYou are correct, however I removed it again, because I did not want to break
Rick's board. He did add a commit to the last pull request that removes these
two lines and adjusts his board accordingly, but it is not in the current one.Hi Likas
Thanks for your explanation.
Quoted 8 lines
Quoted 2 lines
RIck's commit as below
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlWhen we run U-Boot in S-mode the BBL runs from
0x80000000so this two lines corrupts BBL instructions.If this is important for some board then please have it around #ifdef.
Hi Anup
In the discussion as below :
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlI try to solve this issue with the aptch
[PATCH] riscv: ax25-ae350: Pass dtb address to u-boot with a1 registerarch/riscv/cpu/start.S +0
-2- li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0)board/AndesTech/ax25-ae350/ax25-ae350.c +1
-1void *board_fdt_blob_setup (void ) { -void **ptr = (void *)CONFIG_SYS_SDRAM_BASE ; +void **ptr = (void *)&prior_stage_fdt_address;in the previous pull request.
But Bin do not agree with that I use
prior_stage_fdt_addressinboard_fdt_blob_setup( )
I try to explain why I use it like that way.
Then Bin have not any reply in the following mail. Finally I decide to drop this patch in the next pull request.Quoted 3 lines
Hi Bin
How do you think about I recovery this patch to fix this issue ?
Actually, previous booting stage can pass location of FDT stored in flash to U-Boot. U-Boot requires FDT at a DRAM location which it can modify in-place before passing on to Linux kernel so we should relocate the FDT passed by previous booting stage to some board specific DRAM location.
Quoted 9 lines
Quoted 8 lines
My suggestion is as follows:
Instead of
SDRAM_BASE, we can have new board specific configCONFIG_RISCV_PRIOR_FDT_BASEIf
CONFIG_RISCV_PRIOR_FDT_BASEis defined/selected by config then instart.Scopy-over the FDT from location pointed by "a1" register to location pointed byCONFIG_RISCV_PRIOR_FDT_BASE.Hi Anup
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
It can not achieve dtb delivery at runtime.
Can you elaborate why?
CONFIG_RISCV_PRIOR_FDT_BASEis determined at compile time. I am wondering how it can be modified at run time ?I think you miss-understood my suggestion. I did not meant changing
CONFIG_RISCV_PRIOR_FDT_BASEat runtime.Quoted 2 lines
Quoted 9 lines
Quoted 3 lines
Quoted 1 line
I am sure we can always relocate FDT passed by previous stage to some safer location and use it from there.
My original patch also can achieve that dtb passed by a1 and relocated and boot.
Great !!!
Why not update your original patch to relocate FDT and use FDT from safer location?
Good question.
Above can see the question I ask for Bin :
How do you think about I recovery this patch to fix this issue ?Quoted 9 lines
Quoted 5 lines
Quoted 1 line
Before you talking about
CONFIG_RISCV_PRIOR_FDT_BASE!Can you explain why you need
CONFIG_OF_BOARD?
Why can you not useCONFIG_OF_PRIOR_STAGE?You can find the discussion as below:
https://patchwork.ozlabs.org/patch/988884/If I understand correctly, so far we have two scenarios to support:
Quoted 8 lines
1. U-Boot is booting directly from reset vector from ROM. This canonical way to support DT is via
CONFIG_OF_EMBEDorCONFIG_OF_SEPARATE. In such configuration, there is no any previous bootloader so the concept ofCONFIG_OF_PRIOR_STAGEdoes not apply.2. U-Boot is booting from previous bootloader, and DT is passed in a1 register. Such configuration we can use
CONFIG_OF_PRIOR_STAGE.
I use the 3rd way, CONFIG_OF_BOARD.
It can be found in README.
And can be chosen by make menuconfig
It is the most flexible way that I can implement my own board_fdt_blob_setup( ) which can both support boot from RAM or ROM without any configuration change. I will indeed use CONFIG_OF_EMBED when u-boot is in debug stage.
prior_stage_fdt_address is just a way that a variable was declared in data section.
It offer a temp memory to preserve a1 for fdt relocation. If I rename prior_stage_fdt_address as fdt_preserve_address, then it will look like not belong to CONFIG_OF_PRIOR_STAGE.
But the code will be somehow duplicate. That is why I recycle it and try to use prior_stage_fdt_address in board_fdt_blob_setup( )
B.R
Rick
Quoted 2 lines
Regards,
Bin
PATCH v5 4/4 riscv: Remove redundant a2 store on DRAM base in start.S
Rick Chen <[email protected]> 於 2018年11月29日 週四 下午6:42寫道:
Quoted 188 lines
Bin Meng <[email protected]> 於 2018年11月27日 週二 下午6:07寫道:
Quoted 169 lines
Hi Rick,
Quoted 153 lines · Rick Chen
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午3:56寫道:
Quoted 151 lines · Rick Chen
Quoted 149 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午2:40寫道:
Quoted 133 lines · Rick Chen
Quoted 117 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午2:14寫道:
Quoted 115 lines · On Tue, 27 Nov, 2018, 11:38 AM Rick Chen <[email protected] wrote:
Quoted 111 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午1:47寫道:
Quoted 97 lines · Anup Patel
Quoted 95 lines · Rick Chen
Quoted 84 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 上午11:28寫道:
Quoted 55 lines · Rick Chen
Currently, the RISC-V U-Boot is saving a2 register at
CONFIG_SYS_DRAM_BASE in start.S which does not make sense because
there is no information passed by previous booting stage in a2
register.This patch removes redundant a2 store on DRAM base.
Signed-off-by: Anup Patel <[email protected]>
---
arch/riscv/cpu/start.S | 2 --
1 file changed, 2 deletions(-)diff --git a/arch/riscv/cpu/start.S b/arch/riscv/cpu/start.S index
704190f946..e4276e8e19 100644
--- a/arch/riscv/cpu/start.S
+++ b/arch/riscv/cpu/start.S
@@ -38,8 +38,6 @@ _start:
mv s0, a0
mv s1, a1- li t0, CONFIG_SYS_SDRAM_BASE
- SREG a2, 0(t0)
la t0, trap_entry
#ifdef CONFIG_RISCV_SMODE
csrw stvec, t0
--This is weird. I remember these two lines were already removed by
Lukas's patch series before? Did not have time to dig out the history
though.Regards,
BinYou are correct, however I removed it again, because I did not want to break
Rick's board. He did add a commit to the last pull request that removes these
two lines and adjusts his board accordingly, but it is not in the current one.Hi Likas
Thanks for your explanation.
RIck's commit as below
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlWhen we run U-Boot in S-mode the BBL runs from 0x80000000 so this
two lines corrupts BBL instructions.If this is important for some board then please have it around #ifdef.
Hi Anup
In the discussion as below :
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlI try to solve this issue with the aptch
[PATCH] riscv: ax25-ae350: Pass dtb address to u-boot with a1 registerarch/riscv/cpu/start.S +0
-2- li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0)board/AndesTech/ax25-ae350/ax25-ae350.c +1
-1void *board_fdt_blob_setup (void ) { -void **ptr = (void *)CONFIG_SYS_SDRAM_BASE ; +void **ptr = (void *)&prior_stage_fdt_address;in the previous pull request.
But Bin do not agree with that I use
prior_stage_fdt_addressinboard_fdt_blob_setup( )
I try to explain why I use it like that way.
Then Bin have not any reply in the following mail. Finally I decide to drop this patch in the next pull request.Quoted 3 lines
Hi Bin
How do you think about I recovery this patch to fix this issue ?
Actually, previous booting stage can pass location of FDT stored in flash to U-Boot. U-Boot requires FDT at a DRAM location which it can modify in-place before passing on to Linux kernel so we should relocate the FDT passed by previous booting stage to some board specific DRAM location.
Quoted 9 lines
Quoted 8 lines
My suggestion is as follows:
Instead of
SDRAM_BASE, we can have new board specific configCONFIG_RISCV_PRIOR_FDT_BASEIf
CONFIG_RISCV_PRIOR_FDT_BASEis defined/selected by config then instart.Scopy-over the FDT from location pointed by "a1" register to location pointed byCONFIG_RISCV_PRIOR_FDT_BASE.Hi Anup
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
It can not achieve dtb delivery at runtime.
Can you elaborate why?
CONFIG_RISCV_PRIOR_FDT_BASEis determined at compile time. I am wondering how it can be modified at run time ?I think you miss-understood my suggestion. I did not meant changing
CONFIG_RISCV_PRIOR_FDT_BASEat runtime.Quoted 2 lines
Quoted 9 lines
Quoted 3 lines
Quoted 1 line
I am sure we can always relocate FDT passed by previous stage to some safer location and use it from there.
My original patch also can achieve that dtb passed by a1 and relocated and boot.
Great !!!
Why not update your original patch to relocate FDT and use FDT from safer location?
Good question.
Above can see the question I ask for Bin :
How do you think about I recovery this patch to fix this issue ?Quoted 9 lines
Quoted 5 lines
Quoted 1 line
Before you talking about
CONFIG_RISCV_PRIOR_FDT_BASE!Can you explain why you need
CONFIG_OF_BOARD?
Why can you not useCONFIG_OF_PRIOR_STAGE?You can find the discussion as below:
https://patchwork.ozlabs.org/patch/988884/If I understand correctly, so far we have two scenarios to support:
Quoted 8 lines
1. U-Boot is booting directly from reset vector from ROM. This canonical way to support DT is via
CONFIG_OF_EMBEDorCONFIG_OF_SEPARATE. In such configuration, there is no any previous bootloader so the concept ofCONFIG_OF_PRIOR_STAGEdoes not apply.2. U-Boot is booting from previous bootloader, and DT is passed in a1 register. Such configuration we can use
CONFIG_OF_PRIOR_STAGE.I use the 3rd way,
CONFIG_OF_BOARD.
It can be found in README.
And can be chosen by make menuconfigIt is the most flexible way that I can implement my own
board_fdt_blob_setup( )which can both support boot from RAM or ROM without any configuration change. I will indeed useCONFIG_OF_EMBEDwhen u-boot is in debug stage.
Quoted 8 lines
prior_stage_fdt_addressis just a way that a variable was declared in data section.
It offer a temp memory to preserve a1 for fdt relocation. If I renameprior_stage_fdt_addressasfdt_preserve_address, then it will look like not belong toCONFIG_OF_PRIOR_STAGE.
But the code will be somehow duplicate. That is why I recycle it and try to useprior_stage_fdt_addressinboard_fdt_blob_setup( )
If you still think it is not ok.
I can try another way to overcome it. :)
Maybe I can try Alex's way.
Rick
Quoted 5 lines
B.R
RickQuoted 2 lines
Regards,
Bin
PATCH v5 4/4 riscv: Remove redundant a2 store on DRAM base in start.S
In reply to Rick ChenHi Rick,
Quoted 180 lines · Rick Chen
Bin Meng <[email protected]> 於 2018年11月27日 週二 下午6:07寫道:
Quoted 169 lines
Hi Rick,
Quoted 153 lines · Rick Chen
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午3:56寫道:
Quoted 151 lines · Rick Chen
Quoted 149 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午2:40寫道:
Quoted 133 lines · Rick Chen
Quoted 117 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午2:14寫道:
Quoted 115 lines · On Tue, 27 Nov, 2018, 11:38 AM Rick Chen <[email protected] wrote:
Quoted 111 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午1:47寫道:
Quoted 97 lines · Anup Patel
Quoted 95 lines · Rick Chen
Quoted 84 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 上午11:28寫道:
Quoted 55 lines · Rick Chen
Currently, the RISC-V U-Boot is saving a2 register at
CONFIG_SYS_DRAM_BASE in start.S which does not make sense because
there is no information passed by previous booting stage in a2
register.This patch removes redundant a2 store on DRAM base.
Signed-off-by: Anup Patel <[email protected]>
---
arch/riscv/cpu/start.S | 2 --
1 file changed, 2 deletions(-)diff --git a/arch/riscv/cpu/start.S b/arch/riscv/cpu/start.S index
704190f946..e4276e8e19 100644
--- a/arch/riscv/cpu/start.S
+++ b/arch/riscv/cpu/start.S
@@ -38,8 +38,6 @@ _start:
mv s0, a0
mv s1, a1- li t0, CONFIG_SYS_SDRAM_BASE
- SREG a2, 0(t0)
la t0, trap_entry
#ifdef CONFIG_RISCV_SMODE
csrw stvec, t0
--This is weird. I remember these two lines were already removed by
Lukas's patch series before? Did not have time to dig out the history
though.Regards,
BinYou are correct, however I removed it again, because I did not want to break
Rick's board. He did add a commit to the last pull request that removes these
two lines and adjusts his board accordingly, but it is not in the current one.Hi Likas
Thanks for your explanation.
RIck's commit as below
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlWhen we run U-Boot in S-mode the BBL runs from 0x80000000 so this
two lines corrupts BBL instructions.If this is important for some board then please have it around #ifdef.
Hi Anup
In the discussion as below :
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlI try to solve this issue with the aptch
[PATCH] riscv: ax25-ae350: Pass dtb address to u-boot with a1 registerarch/riscv/cpu/start.S +0
-2- li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0)board/AndesTech/ax25-ae350/ax25-ae350.c +1
-1void *board_fdt_blob_setup (void ) { -void **ptr = (void *)CONFIG_SYS_SDRAM_BASE ; +void **ptr = (void *)&prior_stage_fdt_address;in the previous pull request.
But Bin do not agree with that I use
prior_stage_fdt_addressinboard_fdt_blob_setup( )
I try to explain why I use it like that way.
Then Bin have not any reply in the following mail. Finally I decide to drop this patch in the next pull request.Quoted 3 lines
Hi Bin
How do you think about I recovery this patch to fix this issue ?
Actually, previous booting stage can pass location of FDT stored in flash to U-Boot. U-Boot requires FDT at a DRAM location which it can modify in-place before passing on to Linux kernel so we should relocate the FDT passed by previous booting stage to some board specific DRAM location.
Quoted 9 lines
Quoted 8 lines
My suggestion is as follows:
Instead of
SDRAM_BASE, we can have new board specific configCONFIG_RISCV_PRIOR_FDT_BASEIf
CONFIG_RISCV_PRIOR_FDT_BASEis defined/selected by config then instart.Scopy-over the FDT from location pointed by "a1" register to location pointed byCONFIG_RISCV_PRIOR_FDT_BASE.Hi Anup
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
It can not achieve dtb delivery at runtime.
Can you elaborate why?
CONFIG_RISCV_PRIOR_FDT_BASEis determined at compile time. I am wondering how it can be modified at run time ?I think you miss-understood my suggestion. I did not meant changing
CONFIG_RISCV_PRIOR_FDT_BASEat runtime.Quoted 2 lines
Quoted 9 lines
Quoted 3 lines
Quoted 1 line
I am sure we can always relocate FDT passed by previous stage to some safer location and use it from there.
My original patch also can achieve that dtb passed by a1 and relocated and boot.
Great !!!
Why not update your original patch to relocate FDT and use FDT from safer location?
Good question.
Above can see the question I ask for Bin :
How do you think about I recovery this patch to fix this issue ?Quoted 9 lines
Quoted 5 lines
Quoted 1 line
Before you talking about
CONFIG_RISCV_PRIOR_FDT_BASE!Can you explain why you need
CONFIG_OF_BOARD?
Why can you not useCONFIG_OF_PRIOR_STAGE?You can find the discussion as below:
https://patchwork.ozlabs.org/patch/988884/If I understand correctly, so far we have two scenarios to support:
Quoted 8 lines
1. U-Boot is booting directly from reset vector from ROM. This canonical way to support DT is via
CONFIG_OF_EMBEDorCONFIG_OF_SEPARATE. In such configuration, there is no any previous bootloader so the concept ofCONFIG_OF_PRIOR_STAGEdoes not apply.2. U-Boot is booting from previous bootloader, and DT is passed in a1 register. Such configuration we can use
CONFIG_OF_PRIOR_STAGE.
Quoted 8 lines
I use the 3rd way,
CONFIG_OF_BOARD.
It can be found in README.
And can be chosen by make menuconfigIt is the most flexible way that I can implement my own
board_fdt_blob_setup( )which can both support boot from RAM or ROM without any configuration change. I will indeed useCONFIG_OF_EMBEDwhen u-boot is in debug stage.
What I don't understand is that if U-Boot is booting directly from the reset vector, there is no a1 passed by anyone. U-Boot itself should figure out a way to determine the DT and that's how CONFIG_OF_EMBED or CONFIG_OF_SEPARATE is doing. Can you elaborate this configuration?
Quoted 8 lines
prior_stage_fdt_addressis just a way that a variable was declared in data section.
It offer a temp memory to preserve a1 for fdt relocation. If I renameprior_stage_fdt_addressasfdt_preserve_address, then it will look like not belong toCONFIG_OF_PRIOR_STAGE.
But the code will be somehow duplicate. That is why I recycle it and try to useprior_stage_fdt_addressinboard_fdt_blob_setup( )
+ Simon's comment to hear his thoughts.
Regards,
Bin
PATCH v5 4/4 riscv: Remove redundant a2 store on DRAM base in start.S
Bin Meng <[email protected]> 於 2018年11月30日 週五 上午9:48寫道:
Quoted 193 lines
Hi Rick,
Quoted 180 lines · Rick Chen
Bin Meng <[email protected]> 於 2018年11月27日 週二 下午6:07寫道:
Quoted 169 lines
Hi Rick,
Quoted 153 lines · Rick Chen
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午3:56寫道:
Quoted 151 lines · Rick Chen
Quoted 149 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午2:40寫道:
Quoted 133 lines · Rick Chen
Quoted 117 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午2:14寫道:
Quoted 115 lines · On Tue, 27 Nov, 2018, 11:38 AM Rick Chen <[email protected] wrote:
Quoted 111 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午1:47寫道:
Quoted 97 lines · Anup Patel
Quoted 95 lines · Rick Chen
Quoted 87 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 上午11:28寫道:
On Tue, Nov 27, 2018 at 8:50 AM Rick Chen <[email protected]> wrote:
Currently, the RISC-V U-Boot is saving a2 register at
CONFIG_SYS_DRAM_BASE in start.S which does not make sense because
there is no information passed by previous booting stage in a2
register.This patch removes redundant a2 store on DRAM base.
Signed-off-by: Anup Patel <[email protected]>
---
arch/riscv/cpu/start.S | 2 --
1 file changed, 2 deletions(-)diff --git a/arch/riscv/cpu/start.S b/arch/riscv/cpu/start.S index
704190f946..e4276e8e19 100644
--- a/arch/riscv/cpu/start.S
+++ b/arch/riscv/cpu/start.S
@@ -38,8 +38,6 @@ _start:
mv s0, a0
mv s1, a1- li t0, CONFIG_SYS_SDRAM_BASE
- SREG a2, 0(t0)
la t0, trap_entry
#ifdef CONFIG_RISCV_SMODE
csrw stvec, t0
--This is weird. I remember these two lines were already removed by
Lukas's patch series before? Did not have time to dig out the history
though.Regards,
BinYou are correct, however I removed it again, because I did not want to break
Rick's board. He did add a commit to the last pull request that removes these
two lines and adjusts his board accordingly, but it is not in the current one.Hi Likas
Thanks for your explanation.
RIck's commit as below
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlWhen we run U-Boot in S-mode the BBL runs from 0x80000000 so this
two lines corrupts BBL instructions.If this is important for some board then please have it around #ifdef.
Hi Anup
In the discussion as below :
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlI try to solve this issue with the aptch
[PATCH] riscv: ax25-ae350: Pass dtb address to u-boot with a1 register
diff --git a/arch/riscv/cpu/start.S b/arch/riscv/cpu/start.S
- li t0, CONFIG_SYS_SDRAM_BASE
- SREG a2, 0(t0)diff --git a/board/AndesTech/ax25-ae350/ax25-ae350.c
b/board/AndesTech/ax25-ae350/ax25-ae350.c
void *board_fdt_blob_setup(void)
{
- void **ptr = (void *)CONFIG_SYS_SDRAM_BASE;
+ void **ptr = (void *)&prior_stage_fdt_address;in the previous pull request.
But Bin do not agree with that I use prior_stage_fdt_address in
board_fdt_blob_setup( )
I try to explain why I use it like that way.
Then Bin have not any reply in the following mail.
Finally I decide to drop this patch in the next pull request.Hi Bin
How do you think about I recovery this patch to fix this issue ?
Actually, previous booting stage can pass location of FDT stored in flash to U-Boot. U-Boot requires FDT at a DRAM location which it can modify in-place before passing on to Linux kernel so we should relocate the FDT passed by previous booting stage to some board specific DRAM location.
Quoted 9 lines
Quoted 8 lines
My suggestion is as follows:
Instead of
SDRAM_BASE, we can have new board specific configCONFIG_RISCV_PRIOR_FDT_BASEIf
CONFIG_RISCV_PRIOR_FDT_BASEis defined/selected by config then instart.Scopy-over the FDT from location pointed by "a1" register to location pointed byCONFIG_RISCV_PRIOR_FDT_BASE.Hi Anup
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
It can not achieve dtb delivery at runtime.
Can you elaborate why?
CONFIG_RISCV_PRIOR_FDT_BASEis determined at compile time. I am wondering how it can be modified at run time ?I think you miss-understood my suggestion. I did not meant changing
CONFIG_RISCV_PRIOR_FDT_BASEat runtime.Quoted 2 lines
Quoted 9 lines
Quoted 3 lines
Quoted 1 line
I am sure we can always relocate FDT passed by previous stage to some safer location and use it from there.
My original patch also can achieve that dtb passed by a1 and relocated and boot.
Great !!!
Why not update your original patch to relocate FDT and use FDT from safer location?
Good question.
Above can see the question I ask for Bin :
How do you think about I recovery this patch to fix this issue ?Quoted 9 lines
Quoted 5 lines
Quoted 1 line
Before you talking about
CONFIG_RISCV_PRIOR_FDT_BASE!Can you explain why you need
CONFIG_OF_BOARD?
Why can you not useCONFIG_OF_PRIOR_STAGE?You can find the discussion as below:
https://patchwork.ozlabs.org/patch/988884/If I understand correctly, so far we have two scenarios to support:
Quoted 8 lines
1. U-Boot is booting directly from reset vector from ROM. This canonical way to support DT is via
CONFIG_OF_EMBEDorCONFIG_OF_SEPARATE. In such configuration, there is no any previous bootloader so the concept ofCONFIG_OF_PRIOR_STAGEdoes not apply.2. U-Boot is booting from previous bootloader, and DT is passed in a1 register. Such configuration we can use
CONFIG_OF_PRIOR_STAGE.Quoted 8 lines
I use the 3rd way,
CONFIG_OF_BOARD.
It can be found in README.
And can be chosen by make menuconfigIt is the most flexible way that I can implement my own
board_fdt_blob_setup( )which can both support boot from RAM or ROM without any configuration change. I will indeed useCONFIG_OF_EMBEDwhen u-boot is in debug stage.
Quoted 5 lines
What I don't understand is that if U-Boot is booting directly from the reset vector, there is no a1 passed by anyone. U-Boot itself should figure out a way to determine the DT and that's how
CONFIG_OF_EMBEDorCONFIG_OF_SEPARATEis doing. Can you elaborate this configuration?
I use CONFIG_OF_BOARD and board_fdt_blob_setup as below:
void *board_fdt_blob_setup(void)
{
void **ptr = (void *)CONFIG_SYS_SDRAM_BASE;
if (fdt_magic(*ptr) == FDT_MAGIC)
return (void *)*ptr;
return (void *)CONFIG_SYS_FDT_BASE;
}
1. When booting from RAM
a1 can be passed by loader and reserved in CONFIG_SYS_SDRAM_BASE
temporarily.
2. When booting from FLASH
a1 can NOT be passed by loader and reserved inCONFIG_SYS_SDRAM_BASE temporarily.
So dtb shall be get from CONFIG_SYS_FDT_BASE (flash base) which
the dtb shall be pre-burned in this flash space..
Or CONFIG_SYS_FDT_BASE maybe a memory map space (NOT RAM or ROM)
provided by HW.
That is why I mean using CONFIG_OF_BOARD can support both boot from ram or rom with one configuration.
Regards,
Rick
Quoted 13 lines
Quoted 8 lines
prior_stage_fdt_addressis just a way that a variable was declared in data section.
It offer a temp memory to preserve a1 for fdt relocation. If I renameprior_stage_fdt_addressasfdt_preserve_address, then it will look like not belong toCONFIG_OF_PRIOR_STAGE.
But the code will be somehow duplicate. That is why I recycle it and try to useprior_stage_fdt_addressinboard_fdt_blob_setup( )+ Simon's comment to hear his thoughts.
Regards,
Bin
PATCH v5 4/4 riscv: Remove redundant a2 store on DRAM base in start.S
Hi Rick,
Quoted 220 lines · Rick Chen
Bin Meng <[email protected]> 於 2018年11月30日 週五 上午9:48寫道:
Quoted 193 lines
Hi Rick,
Quoted 180 lines · Rick Chen
Bin Meng <[email protected]> 於 2018年11月27日 週二 下午6:07寫道:
Quoted 169 lines
Hi Rick,
Quoted 153 lines · Rick Chen
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午3:56寫道:
Quoted 151 lines · Rick Chen
Quoted 149 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午2:40寫道:
Quoted 133 lines · Rick Chen
Quoted 117 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午2:14寫道:
Quoted 115 lines · On Tue, 27 Nov, 2018, 11:38 AM Rick Chen <[email protected] wrote:
Quoted 111 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午1:47寫道:
Quoted 97 lines · Anup Patel
Quoted 95 lines · Rick Chen
Anup Patel <[email protected]> 於 2018年11月27日 週二 上午11:28寫道:
On Tue, Nov 27, 2018 at 8:50 AM Rick Chen <[email protected]> wrote:
Currently, the RISC-V U-Boot is saving a2 register at
CONFIG_SYS_DRAM_BASE in start.S which does not make sense because
there is no information passed by previous booting stage in a2
register.This patch removes redundant a2 store on DRAM base.
Signed-off-by: Anup Patel <[email protected]>
---
arch/riscv/cpu/start.S | 2 --
1 file changed, 2 deletions(-)diff --git a/arch/riscv/cpu/start.S b/arch/riscv/cpu/start.S index
704190f946..e4276e8e19 100644
--- a/arch/riscv/cpu/start.S
+++ b/arch/riscv/cpu/start.S
@@ -38,8 +38,6 @@ _start:
mv s0, a0
mv s1, a1- li t0, CONFIG_SYS_SDRAM_BASE
- SREG a2, 0(t0)
la t0, trap_entry
#ifdef CONFIG_RISCV_SMODE
csrw stvec, t0
--This is weird. I remember these two lines were already removed by
Lukas's patch series before? Did not have time to dig out the history
though.Regards,
BinYou are correct, however I removed it again, because I did not want to break
Rick's board. He did add a commit to the last pull request that removes these
two lines and adjusts his board accordingly, but it is not in the current one.Hi Likas
Thanks for your explanation.
RIck's commit as below
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlWhen we run U-Boot in S-mode the BBL runs from 0x80000000 so this
two lines corrupts BBL instructions.If this is important for some board then please have it around #ifdef.
Hi Anup
In the discussion as below :
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlI try to solve this issue with the aptch
[PATCH] riscv: ax25-ae350: Pass dtb address to u-boot with a1 register
diff --git a/arch/riscv/cpu/start.S b/arch/riscv/cpu/start.S
- li t0, CONFIG_SYS_SDRAM_BASE
- SREG a2, 0(t0)diff --git a/board/AndesTech/ax25-ae350/ax25-ae350.c
b/board/AndesTech/ax25-ae350/ax25-ae350.c
void *board_fdt_blob_setup(void)
{
- void **ptr = (void *)CONFIG_SYS_SDRAM_BASE;
+ void **ptr = (void *)&prior_stage_fdt_address;in the previous pull request.
But Bin do not agree with that I use prior_stage_fdt_address in
board_fdt_blob_setup( )
I try to explain why I use it like that way.
Then Bin have not any reply in the following mail.
Finally I decide to drop this patch in the next pull request.Hi Bin
How do you think about I recovery this patch to fix this issue ?
Actually, previous booting stage can pass location of FDT stored in flash
to U-Boot. U-Boot requires FDT at a DRAM location which it can modify
in-place before passing on to Linux kernel so we should relocate the FDT
passed by previous booting stage to some board specific DRAM location.Quoted 9 lines
Quoted 8 lines
My suggestion is as follows:
Instead of SDRAM_BASE, we can have new board specific config
CONFIG_RISCV_PRIOR_FDT_BASEIf CONFIG_RISCV_PRIOR_FDT_BASE is defined/selected by
config then in start.S copy-over the FDT from location pointed by
"a1" register to location pointed by CONFIG_RISCV_PRIOR_FDT_BASE.Hi Anup
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
It can not achieve dtb delivery at runtime.
Can you elaborate why?
CONFIG_RISCV_PRIOR_FDT_BASEis determined at compile time. I am wondering how it can be modified at run time ?I think you miss-understood my suggestion. I did not meant changing
CONFIG_RISCV_PRIOR_FDT_BASEat runtime.Quoted 2 lines
Quoted 9 lines
Quoted 3 lines
Quoted 1 line
I am sure we can always relocate FDT passed by previous stage to some safer location and use it from there.
My original patch also can achieve that dtb passed by a1 and relocated and boot.
Great !!!
Why not update your original patch to relocate FDT and use FDT from safer location?
Good question.
Above can see the question I ask for Bin :
How do you think about I recovery this patch to fix this issue ?Quoted 9 lines
Quoted 5 lines
Quoted 1 line
Before you talking about
CONFIG_RISCV_PRIOR_FDT_BASE!Can you explain why you need
CONFIG_OF_BOARD?
Why can you not useCONFIG_OF_PRIOR_STAGE?You can find the discussion as below:
https://patchwork.ozlabs.org/patch/988884/If I understand correctly, so far we have two scenarios to support:
Quoted 8 lines
1. U-Boot is booting directly from reset vector from ROM. This canonical way to support DT is via
CONFIG_OF_EMBEDorCONFIG_OF_SEPARATE. In such configuration, there is no any previous bootloader so the concept ofCONFIG_OF_PRIOR_STAGEdoes not apply.2. U-Boot is booting from previous bootloader, and DT is passed in a1 register. Such configuration we can use
CONFIG_OF_PRIOR_STAGE.Quoted 8 lines
I use the 3rd way,
CONFIG_OF_BOARD.
It can be found in README.
And can be chosen by make menuconfigIt is the most flexible way that I can implement my own
board_fdt_blob_setup( )which can both support boot from RAM or ROM without any configuration change. I will indeed useCONFIG_OF_EMBEDwhen u-boot is in debug stage.Quoted 5 lines
What I don't understand is that if U-Boot is booting directly from the reset vector, there is no a1 passed by anyone. U-Boot itself should figure out a way to determine the DT and that's how
CONFIG_OF_EMBEDorCONFIG_OF_SEPARATEis doing. Can you elaborate this configuration?I use
CONFIG_OF_BOARDandboard_fdt_blob_setupas below:void
*board_fdt_blob_setup(void)
{
void **ptr = (void *)CONFIG_SYS_SDRAM_BASE;
if (fdt_magic(*ptr)==FDT_MAGIC)
return (void *)*ptr;return (void *)CONFIG_SYS_FDT_BASE;
}1. When booting from RAM
a1 can be passed by loader and reserved inCONFIG_SYS_SDRAM_BASE
temporarily.2. When booting from FLASH
a1 can NOT be passed by loader and reserved inCONFIG_SYS_SDRAM_BASEtemporarily.
Quoted 8 lines
So dtb shall be get from
CONFIG_SYS_FDT_BASE(flash base) which
the dtb shall be pre-burned in this flash space..
OrCONFIG_SYS_FDT_BASEmaybe a memory map space (NOT RAM or ROM)
provided by HW.That is why I mean using
CONFIG_OF_BOARDcan support both boot from ram or rom with one configuration.
Thanks for the info. So with the latest info, I now understand you wanted to use CONFIG_OF_BOARD to support both configurations. That makes sense to me, however I still wanted to point out the canonical way to support booting from ROM is via CONFIG_OF_SEPARATE or CONFIG_OF_EMBED. Since your board can support booting from reset vector directly, what's the need to support the booting from RAM configuration? In that configuration, what is the first stage bootloader?
Regards,
Bin
PATCH v5 4/4 riscv: Remove redundant a2 store on DRAM base in start.S
Bin Meng <[email protected]> 於 2018年11月30日 週五 下午2:21寫道:
Quoted 233 lines
Hi Rick,
Quoted 220 lines · Rick Chen
Bin Meng <[email protected]> 於 2018年11月30日 週五 上午9:48寫道:
Quoted 193 lines
Hi Rick,
Quoted 180 lines · Rick Chen
Bin Meng <[email protected]> 於 2018年11月27日 週二 下午6:07寫道:
Quoted 169 lines
Hi Rick,
Quoted 153 lines · Rick Chen
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午3:56寫道:
Quoted 151 lines · Rick Chen
Quoted 149 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午2:40寫道:
Quoted 133 lines · Rick Chen
Quoted 117 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午2:14寫道:
Quoted 115 lines · On Tue, 27 Nov, 2018, 11:38 AM Rick Chen <[email protected] wrote:
Quoted 111 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午1:47寫道:
Quoted 106 lines · Anup Patel
On Tue, Nov 27, 2018 at 10:50 AM Rick Chen <[email protected]> wrote:
Anup Patel <[email protected]> 於 2018年11月27日 週二 上午11:28寫道:
On Tue, Nov 27, 2018 at 8:50 AM Rick Chen <[email protected]> wrote:
Currently, the RISC-V U-Boot is saving a2 register at
CONFIG_SYS_DRAM_BASE in start.S which does not make sense because
there is no information passed by previous booting stage in a2
register.This patch removes redundant a2 store on DRAM base.
Signed-off-by: Anup Patel <[email protected]>
---
arch/riscv/cpu/start.S | 2 --
1 file changed, 2 deletions(-)diff --git a/arch/riscv/cpu/start.S b/arch/riscv/cpu/start.S index
704190f946..e4276e8e19 100644
--- a/arch/riscv/cpu/start.S
+++ b/arch/riscv/cpu/start.S
@@ -38,8 +38,6 @@ _start:
mv s0, a0
mv s1, a1- li t0, CONFIG_SYS_SDRAM_BASE
- SREG a2, 0(t0)
la t0, trap_entry
#ifdef CONFIG_RISCV_SMODE
csrw stvec, t0
--This is weird. I remember these two lines were already removed by
Lukas's patch series before? Did not have time to dig out the history
though.Regards,
BinYou are correct, however I removed it again, because I did not want to break
Rick's board. He did add a commit to the last pull request that removes these
two lines and adjusts his board accordingly, but it is not in the current one.Hi Likas
Thanks for your explanation.
RIck's commit as below
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlWhen we run U-Boot in S-mode the BBL runs from 0x80000000 so this
two lines corrupts BBL instructions.If this is important for some board then please have it around #ifdef.
Hi Anup
In the discussion as below :
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlI try to solve this issue with the aptch
[PATCH] riscv: ax25-ae350: Pass dtb address to u-boot with a1 register
diff --git a/arch/riscv/cpu/start.S b/arch/riscv/cpu/start.S
- li t0, CONFIG_SYS_SDRAM_BASE
- SREG a2, 0(t0)diff --git a/board/AndesTech/ax25-ae350/ax25-ae350.c
b/board/AndesTech/ax25-ae350/ax25-ae350.c
void *board_fdt_blob_setup(void)
{
- void **ptr = (void *)CONFIG_SYS_SDRAM_BASE;
+ void **ptr = (void *)&prior_stage_fdt_address;in the previous pull request.
But Bin do not agree with that I use prior_stage_fdt_address in
board_fdt_blob_setup( )
I try to explain why I use it like that way.
Then Bin have not any reply in the following mail.
Finally I decide to drop this patch in the next pull request.Hi Bin
How do you think about I recovery this patch to fix this issue ?
Actually, previous booting stage can pass location of FDT stored in flash
to U-Boot. U-Boot requires FDT at a DRAM location which it can modify
in-place before passing on to Linux kernel so we should relocate the FDT
passed by previous booting stage to some board specific DRAM location.My suggestion is as follows:
Instead of SDRAM_BASE, we can have new board specific config
CONFIG_RISCV_PRIOR_FDT_BASEIf CONFIG_RISCV_PRIOR_FDT_BASE is defined/selected by
config then in start.S copy-over the FDT from location pointed by
"a1" register to location pointed by CONFIG_RISCV_PRIOR_FDT_BASE.Hi Anup
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
It can not achieve dtb delivery at runtime.
Can you elaborate why?
CONFIG_RISCV_PRIOR_FDT_BASEis determined at compile time. I am wondering how it can be modified at run time ?I think you miss-understood my suggestion. I did not meant changing
CONFIG_RISCV_PRIOR_FDT_BASEat runtime.Quoted 2 lines
Quoted 9 lines
Quoted 3 lines
Quoted 1 line
I am sure we can always relocate FDT passed by previous stage to some safer location and use it from there.
My original patch also can achieve that dtb passed by a1 and relocated and boot.
Great !!!
Why not update your original patch to relocate FDT and use FDT from safer location?
Good question.
Above can see the question I ask for Bin :
How do you think about I recovery this patch to fix this issue ?Quoted 9 lines
Quoted 5 lines
Quoted 1 line
Before you talking about
CONFIG_RISCV_PRIOR_FDT_BASE!Can you explain why you need
CONFIG_OF_BOARD?
Why can you not useCONFIG_OF_PRIOR_STAGE?You can find the discussion as below:
https://patchwork.ozlabs.org/patch/988884/If I understand correctly, so far we have two scenarios to support:
Quoted 8 lines
1. U-Boot is booting directly from reset vector from ROM. This canonical way to support DT is via
CONFIG_OF_EMBEDorCONFIG_OF_SEPARATE. In such configuration, there is no any previous bootloader so the concept ofCONFIG_OF_PRIOR_STAGEdoes not apply.2. U-Boot is booting from previous bootloader, and DT is passed in a1 register. Such configuration we can use
CONFIG_OF_PRIOR_STAGE.Quoted 8 lines
I use the 3rd way,
CONFIG_OF_BOARD.
It can be found in README.
And can be chosen by make menuconfigIt is the most flexible way that I can implement my own
board_fdt_blob_setup( )which can both support boot from RAM or ROM without any configuration change. I will indeed useCONFIG_OF_EMBEDwhen u-boot is in debug stage.Quoted 5 lines
What I don't understand is that if U-Boot is booting directly from the reset vector, there is no a1 passed by anyone. U-Boot itself should figure out a way to determine the DT and that's how
CONFIG_OF_EMBEDorCONFIG_OF_SEPARATEis doing. Can you elaborate this configuration?I use
CONFIG_OF_BOARDandboard_fdt_blob_setupas below:void
*board_fdt_blob_setup(void)
{
void **ptr = (void *)CONFIG_SYS_SDRAM_BASE;
if (fdt_magic(*ptr)==FDT_MAGIC)
return (void *)*ptr;return (void *)CONFIG_SYS_FDT_BASE;
}1. When booting from RAM
a1 can be passed by loader and reserved inCONFIG_SYS_SDRAM_BASE
temporarily.2. When booting from FLASH
a1 can NOT be passed by loader and reserved inCONFIG_SYS_SDRAM_BASEtemporarily.Quoted 8 lines
So dtb shall be get from
CONFIG_SYS_FDT_BASE(flash base) which
the dtb shall be pre-burned in this flash space..
OrCONFIG_SYS_FDT_BASEmaybe a memory map space (NOT RAM or ROM)
provided by HW.That is why I mean using
CONFIG_OF_BOARDcan support both boot from ram or rom with one configuration.
Quoted 7 lines
Thanks for the info. So with the latest info, I now understand you wanted to use
CONFIG_OF_BOARDto support both configurations. That makes sense to me, however I still wanted to point out the canonical way to support booting from ROM is viaCONFIG_OF_SEPARATEorCONFIG_OF_EMBED. Since your board can support booting from reset vector directly, what's the need to support the booting from RAM configuration?
I will develop u-boot via booting from ram. It will easy for debugging. After develop complete.
It will be good for demo via booting from flash.
With one configuration, it can decrease to make mistake with wrong configuration between 2 configuration
for ram or rom individually.
In that configuration, what is the first stage
Quoted 1 line
bootloader?
When booting from ram
GDB will be the first stage to load u-boot.
So it is not good for demo, because it need a pc to fire gdb.
B.R
Rick
Quoted 3 lines
Regards,
Bin
PATCH v5 4/4 riscv: Remove redundant a2 store on DRAM base in start.S
Hi Rick,
Quoted 250 lines · Rick Chen
Bin Meng <[email protected]> 於 2018年11月30日 週五 下午2:21寫道:
Quoted 233 lines
Hi Rick,
Quoted 220 lines · Rick Chen
Bin Meng <[email protected]> 於 2018年11月30日 週五 上午9:48寫道:
Quoted 193 lines
Hi Rick,
Quoted 180 lines · Rick Chen
Bin Meng <[email protected]> 於 2018年11月27日 週二 下午6:07寫道:
Quoted 169 lines
Hi Rick,
Quoted 153 lines · Rick Chen
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午3:56寫道:
Quoted 151 lines · Rick Chen
Quoted 149 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午2:40寫道:
Quoted 133 lines · Rick Chen
Quoted 117 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午2:14寫道:
Quoted 115 lines · On Tue, 27 Nov, 2018, 11:38 AM Rick Chen <[email protected] wrote:
Quoted 111 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午1:47寫道:
On Tue, Nov 27, 2018 at 11:14 AM Anup Patel <[email protected]> wrote:
On Tue, Nov 27, 2018 at 10:50 AM Rick Chen <[email protected]> wrote:
Anup Patel <[email protected]> 於 2018年11月27日 週二 上午11:28寫道:
On Tue, Nov 27, 2018 at 8:50 AM Rick Chen <[email protected]> wrote:
Currently, the RISC-V U-Boot is saving a2 register at
CONFIG_SYS_DRAM_BASE in start.S which does not make sense because
there is no information passed by previous booting stage in a2
register.This patch removes redundant a2 store on DRAM base.
Signed-off-by: Anup Patel <[email protected]>
---
arch/riscv/cpu/start.S | 2 --
1 file changed, 2 deletions(-)diff --git a/arch/riscv/cpu/start.S b/arch/riscv/cpu/start.S index
704190f946..e4276e8e19 100644
--- a/arch/riscv/cpu/start.S
+++ b/arch/riscv/cpu/start.S
@@ -38,8 +38,6 @@ _start:
mv s0, a0
mv s1, a1- li t0, CONFIG_SYS_SDRAM_BASE
- SREG a2, 0(t0)
la t0, trap_entry
#ifdef CONFIG_RISCV_SMODE
csrw stvec, t0
--This is weird. I remember these two lines were already removed by
Lukas's patch series before? Did not have time to dig out the history
though.Regards,
BinYou are correct, however I removed it again, because I did not want to break
Rick's board. He did add a commit to the last pull request that removes these
two lines and adjusts his board accordingly, but it is not in the current one.Hi Likas
Thanks for your explanation.
RIck's commit as below
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlWhen we run U-Boot in S-mode the BBL runs from 0x80000000 so this
two lines corrupts BBL instructions.If this is important for some board then please have it around #ifdef.
Hi Anup
In the discussion as below :
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlI try to solve this issue with the aptch
[PATCH] riscv: ax25-ae350: Pass dtb address to u-boot with a1 register
diff --git a/arch/riscv/cpu/start.S b/arch/riscv/cpu/start.S
- li t0, CONFIG_SYS_SDRAM_BASE
- SREG a2, 0(t0)diff --git a/board/AndesTech/ax25-ae350/ax25-ae350.c
b/board/AndesTech/ax25-ae350/ax25-ae350.c
void *board_fdt_blob_setup(void)
{
- void **ptr = (void *)CONFIG_SYS_SDRAM_BASE;
+ void **ptr = (void *)&prior_stage_fdt_address;in the previous pull request.
But Bin do not agree with that I use prior_stage_fdt_address in
board_fdt_blob_setup( )
I try to explain why I use it like that way.
Then Bin have not any reply in the following mail.
Finally I decide to drop this patch in the next pull request.Hi Bin
How do you think about I recovery this patch to fix this issue ?
Actually, previous booting stage can pass location of FDT stored in flash
to U-Boot. U-Boot requires FDT at a DRAM location which it can modify
in-place before passing on to Linux kernel so we should relocate the FDT
passed by previous booting stage to some board specific DRAM location.My suggestion is as follows:
Instead of SDRAM_BASE, we can have new board specific config
CONFIG_RISCV_PRIOR_FDT_BASEIf CONFIG_RISCV_PRIOR_FDT_BASE is defined/selected by
config then in start.S copy-over the FDT from location pointed by
"a1" register to location pointed by CONFIG_RISCV_PRIOR_FDT_BASE.Hi Anup
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
It can not achieve dtb delivery at runtime.
Can you elaborate why?
CONFIG_RISCV_PRIOR_FDT_BASEis determined at compile time. I am wondering how it can be modified at run time ?I think you miss-understood my suggestion. I did not meant changing
CONFIG_RISCV_PRIOR_FDT_BASEat runtime.Quoted 2 lines
Quoted 9 lines
Quoted 3 lines
Quoted 1 line
I am sure we can always relocate FDT passed by previous stage to some safer location and use it from there.
My original patch also can achieve that dtb passed by a1 and relocated and boot.
Great !!!
Why not update your original patch to relocate FDT and use FDT from safer location?
Good question.
Above can see the question I ask for Bin :
How do you think about I recovery this patch to fix this issue ?Quoted 9 lines
Quoted 5 lines
Quoted 1 line
Before you talking about
CONFIG_RISCV_PRIOR_FDT_BASE!Can you explain why you need
CONFIG_OF_BOARD?
Why can you not useCONFIG_OF_PRIOR_STAGE?You can find the discussion as below:
https://patchwork.ozlabs.org/patch/988884/If I understand correctly, so far we have two scenarios to support:
Quoted 8 lines
1. U-Boot is booting directly from reset vector from ROM. This canonical way to support DT is via
CONFIG_OF_EMBEDorCONFIG_OF_SEPARATE. In such configuration, there is no any previous bootloader so the concept ofCONFIG_OF_PRIOR_STAGEdoes not apply.2. U-Boot is booting from previous bootloader, and DT is passed in a1 register. Such configuration we can use
CONFIG_OF_PRIOR_STAGE.Quoted 8 lines
I use the 3rd way,
CONFIG_OF_BOARD.
It can be found in README.
And can be chosen by make menuconfigIt is the most flexible way that I can implement my own
board_fdt_blob_setup( )which can both support boot from RAM or ROM without any configuration change. I will indeed useCONFIG_OF_EMBEDwhen u-boot is in debug stage.Quoted 5 lines
What I don't understand is that if U-Boot is booting directly from the reset vector, there is no a1 passed by anyone. U-Boot itself should figure out a way to determine the DT and that's how
CONFIG_OF_EMBEDorCONFIG_OF_SEPARATEis doing. Can you elaborate this configuration?I use
CONFIG_OF_BOARDandboard_fdt_blob_setupas below:void
*board_fdt_blob_setup(void)
{
void **ptr = (void *)CONFIG_SYS_SDRAM_BASE;
if (fdt_magic(*ptr)==FDT_MAGIC)
return (void *)*ptr;return (void *)CONFIG_SYS_FDT_BASE;
}1. When booting from RAM
a1 can be passed by loader and reserved inCONFIG_SYS_SDRAM_BASE
temporarily.2. When booting from FLASH
a1 can NOT be passed by loader and reserved inCONFIG_SYS_SDRAM_BASEtemporarily.Quoted 8 lines
So dtb shall be get from
CONFIG_SYS_FDT_BASE(flash base) which
the dtb shall be pre-burned in this flash space..
OrCONFIG_SYS_FDT_BASEmaybe a memory map space (NOT RAM or ROM)
provided by HW.That is why I mean using
CONFIG_OF_BOARDcan support both boot from ram or rom with one configuration.Quoted 7 lines
Thanks for the info. So with the latest info, I now understand you wanted to use
CONFIG_OF_BOARDto support both configurations. That makes sense to me, however I still wanted to point out the canonical way to support booting from ROM is viaCONFIG_OF_SEPARATEorCONFIG_OF_EMBED. Since your board can support booting from reset vector directly, what's the need to support the booting from RAM configuration?I will develop u-boot via booting from ram. It will easy for debugging. After develop complete.
It will be good for demo via booting from flash.
With one configuration, it can decrease to make mistake with wrong configuration between 2 configuration
for ram or rom individually.
Quoted 7 lines
In that configuration, what is the first stage
Quoted 1 line
bootloader?
When booting from ram
GDB will be the first stage to load u-boot.
So it is not good for demo, because it need a pc to fire gdb.
OK, thanks for the info. For this patch, let's go with your proposal then, but please add some comments in the codes there for people to understand later.
Regards,
Bin
PATCH v5 4/4 riscv: Remove redundant a2 store on DRAM base in start.S
Bin Meng <[email protected]> 於 2018年11月30日 週五 下午2:57寫道:
Quoted 257 lines
Hi Rick,
Quoted 253 lines · Rick Chen
Bin Meng <[email protected]> 於 2018年11月30日 週五 下午2:21寫道:
Quoted 233 lines
Hi Rick,
Quoted 220 lines · Rick Chen
Bin Meng <[email protected]> 於 2018年11月30日 週五 上午9:48寫道:
Quoted 193 lines
Hi Rick,
Quoted 180 lines · Rick Chen
Bin Meng <[email protected]> 於 2018年11月27日 週二 下午6:07寫道:
Quoted 169 lines
Hi Rick,
Quoted 153 lines · Rick Chen
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午3:56寫道:
Quoted 151 lines · Rick Chen
Quoted 149 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午2:40寫道:
Quoted 133 lines · Rick Chen
Quoted 117 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午2:14寫道:
Quoted 115 lines · On Tue, 27 Nov, 2018, 11:38 AM Rick Chen <[email protected] wrote:
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午1:47寫道:
On Tue, Nov 27, 2018 at 11:14 AM Anup Patel <[email protected]> wrote:
On Tue, Nov 27, 2018 at 10:50 AM Rick Chen <[email protected]> wrote:
Anup Patel <[email protected]> 於 2018年11月27日 週二 上午11:28寫道:
On Tue, Nov 27, 2018 at 8:50 AM Rick Chen <[email protected]> wrote:
Currently, the RISC-V U-Boot is saving a2 register at
CONFIG_SYS_DRAM_BASE in start.S which does not make sense because
there is no information passed by previous booting stage in a2
register.This patch removes redundant a2 store on DRAM base.
Signed-off-by: Anup Patel <[email protected]>
---
arch/riscv/cpu/start.S | 2 --
1 file changed, 2 deletions(-)diff --git a/arch/riscv/cpu/start.S b/arch/riscv/cpu/start.S index
704190f946..e4276e8e19 100644
--- a/arch/riscv/cpu/start.S
+++ b/arch/riscv/cpu/start.S
@@ -38,8 +38,6 @@ _start:
mv s0, a0
mv s1, a1- li t0, CONFIG_SYS_SDRAM_BASE
- SREG a2, 0(t0)
la t0, trap_entry
#ifdef CONFIG_RISCV_SMODE
csrw stvec, t0
--This is weird. I remember these two lines were already removed by
Lukas's patch series before? Did not have time to dig out the history
though.Regards,
BinYou are correct, however I removed it again, because I did not want to break
Rick's board. He did add a commit to the last pull request that removes these
two lines and adjusts his board accordingly, but it is not in the current one.Hi Likas
Thanks for your explanation.
RIck's commit as below
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlWhen we run U-Boot in S-mode the BBL runs from 0x80000000 so this
two lines corrupts BBL instructions.If this is important for some board then please have it around #ifdef.
Hi Anup
In the discussion as below :
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlI try to solve this issue with the aptch
[PATCH] riscv: ax25-ae350: Pass dtb address to u-boot with a1 register
diff --git a/arch/riscv/cpu/start.S b/arch/riscv/cpu/start.S
- li t0, CONFIG_SYS_SDRAM_BASE
- SREG a2, 0(t0)diff --git a/board/AndesTech/ax25-ae350/ax25-ae350.c
b/board/AndesTech/ax25-ae350/ax25-ae350.c
void *board_fdt_blob_setup(void)
{
- void **ptr = (void *)CONFIG_SYS_SDRAM_BASE;
+ void **ptr = (void *)&prior_stage_fdt_address;in the previous pull request.
But Bin do not agree with that I use prior_stage_fdt_address in
board_fdt_blob_setup( )
I try to explain why I use it like that way.
Then Bin have not any reply in the following mail.
Finally I decide to drop this patch in the next pull request.Hi Bin
How do you think about I recovery this patch to fix this issue ?
Actually, previous booting stage can pass location of FDT stored in flash
to U-Boot. U-Boot requires FDT at a DRAM location which it can modify
in-place before passing on to Linux kernel so we should relocate the FDT
passed by previous booting stage to some board specific DRAM location.My suggestion is as follows:
Instead of SDRAM_BASE, we can have new board specific config
CONFIG_RISCV_PRIOR_FDT_BASEIf CONFIG_RISCV_PRIOR_FDT_BASE is defined/selected by
config then in start.S copy-over the FDT from location pointed by
"a1" register to location pointed by CONFIG_RISCV_PRIOR_FDT_BASE.Hi Anup
Quoted 8 lines
Quoted 5 lines
It can not achieve dtb delivery at runtime.
Can you elaborate why?
CONFIG_RISCV_PRIOR_FDT_BASEis determined at compile time. I am wondering how it can be modified at run time ?I think you miss-understood my suggestion. I did not meant changing
CONFIG_RISCV_PRIOR_FDT_BASEat runtime.Quoted 2 lines
Quoted 9 lines
Quoted 3 lines
Quoted 1 line
I am sure we can always relocate FDT passed by previous stage to some safer location and use it from there.
My original patch also can achieve that dtb passed by a1 and relocated and boot.
Great !!!
Why not update your original patch to relocate FDT and use FDT from safer location?
Good question.
Above can see the question I ask for Bin :
How do you think about I recovery this patch to fix this issue ?Quoted 9 lines
Quoted 5 lines
Quoted 1 line
Before you talking about
CONFIG_RISCV_PRIOR_FDT_BASE!Can you explain why you need
CONFIG_OF_BOARD?
Why can you not useCONFIG_OF_PRIOR_STAGE?You can find the discussion as below:
https://patchwork.ozlabs.org/patch/988884/If I understand correctly, so far we have two scenarios to support:
Quoted 8 lines
1. U-Boot is booting directly from reset vector from ROM. This canonical way to support DT is via
CONFIG_OF_EMBEDorCONFIG_OF_SEPARATE. In such configuration, there is no any previous bootloader so the concept ofCONFIG_OF_PRIOR_STAGEdoes not apply.2. U-Boot is booting from previous bootloader, and DT is passed in a1 register. Such configuration we can use
CONFIG_OF_PRIOR_STAGE.Quoted 8 lines
I use the 3rd way,
CONFIG_OF_BOARD.
It can be found in README.
And can be chosen by make menuconfigIt is the most flexible way that I can implement my own
board_fdt_blob_setup( )which can both support boot from RAM or ROM without any configuration change. I will indeed useCONFIG_OF_EMBEDwhen u-boot is in debug stage.Quoted 5 lines
What I don't understand is that if U-Boot is booting directly from the reset vector, there is no a1 passed by anyone. U-Boot itself should figure out a way to determine the DT and that's how
CONFIG_OF_EMBEDorCONFIG_OF_SEPARATEis doing. Can you elaborate this configuration?I use
CONFIG_OF_BOARDandboard_fdt_blob_setupas below:void
*board_fdt_blob_setup(void)
{
void **ptr = (void *)CONFIG_SYS_SDRAM_BASE;
if (fdt_magic(*ptr)==FDT_MAGIC)
return (void *)*ptr;return (void *)CONFIG_SYS_FDT_BASE;
}1. When booting from RAM
a1 can be passed by loader and reserved inCONFIG_SYS_SDRAM_BASE
temporarily.2. When booting from FLASH
a1 can NOT be passed by loader and reserved inCONFIG_SYS_SDRAM_BASEtemporarily.Quoted 8 lines
So dtb shall be get from
CONFIG_SYS_FDT_BASE(flash base) which
the dtb shall be pre-burned in this flash space..
OrCONFIG_SYS_FDT_BASEmaybe a memory map space (NOT RAM or ROM)
provided by HW.That is why I mean using
CONFIG_OF_BOARDcan support both boot from ram or rom with one configuration.Quoted 7 lines
Thanks for the info. So with the latest info, I now understand you wanted to use
CONFIG_OF_BOARDto support both configurations. That makes sense to me, however I still wanted to point out the canonical way to support booting from ROM is viaCONFIG_OF_SEPARATEorCONFIG_OF_EMBED. Since your board can support booting from reset vector directly, what's the need to support the booting from RAM configuration?I will develop u-boot via booting from ram. It will easy for debugging. After develop complete.
It will be good for demo via booting from flash.
With one configuration, it can decrease to make mistake with wrong configuration between 2 configuration
for ram or rom individually.In that configuration, what is the first stage
Quoted 1 line
bootloader?
Quoted 8 lines
Quoted 4 lines
When booting from ram
GDB will be the first stage to load u-boot.
So it is not good for demo, because it need a pc to fire gdb.OK, thanks for the info. For this patch, let's go with your proposal then, but please add some comments in the codes there for people to understand later.
Hi Bin
You say go with your proposal :
Does that mean you agree with the following modification ? arch/riscv/cpu/start.S
- li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0)
board/AndesTech/ax25-ae350/ax25-ae350.c
void *board_fdt_blob_setup(void)
{
- void **ptr = (void *)CONFIG_SYS_SDRAM_BASE;
+ void **ptr = (void *)&prior_stage_fdt_address;
And add some comments in this patch for people to understand it.
Or
I still can NOT borrow prior_stage_fdt_address and shall find another way to overcome the problem
after remove the two line in start.S ?
B.R
Rick
Quoted 3 lines
Regards,
Bin
PATCH v5 4/4 riscv: Remove redundant a2 store on DRAM base in start.S
Hi Rick,
Quoted 282 lines · Rick Chen
Bin Meng <[email protected]> 於 2018年11月30日 週五 下午2:57寫道:
Quoted 257 lines
Hi Rick,
Quoted 253 lines · Rick Chen
Bin Meng <[email protected]> 於 2018年11月30日 週五 下午2:21寫道:
Quoted 233 lines
Hi Rick,
Quoted 220 lines · Rick Chen
Bin Meng <[email protected]> 於 2018年11月30日 週五 上午9:48寫道:
Quoted 193 lines
Hi Rick,
Quoted 180 lines · Rick Chen
Bin Meng <[email protected]> 於 2018年11月27日 週二 下午6:07寫道:
Quoted 169 lines
Hi Rick,
Quoted 153 lines · Rick Chen
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午3:56寫道:
Quoted 151 lines · Rick Chen
Quoted 149 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午2:40寫道:
Quoted 133 lines · Rick Chen
Quoted 125 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午2:14寫道:
On Tue, 27 Nov, 2018, 11:38 AM Rick Chen <[email protected] wrote:
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午1:47寫道:
On Tue, Nov 27, 2018 at 11:14 AM Anup Patel <[email protected]> wrote:
On Tue, Nov 27, 2018 at 10:50 AM Rick Chen <[email protected]> wrote:
Anup Patel <[email protected]> 於 2018年11月27日 週二 上午11:28寫道:
On Tue, Nov 27, 2018 at 8:50 AM Rick Chen <[email protected]> wrote:
Currently, the RISC-V U-Boot is saving a2 register at
CONFIG_SYS_DRAM_BASE in start.S which does not make sense because
there is no information passed by previous booting stage in a2
register.This patch removes redundant a2 store on DRAM base.
Signed-off-by: Anup Patel <[email protected]>
---
arch/riscv/cpu/start.S | 2 --
1 file changed, 2 deletions(-)diff --git a/arch/riscv/cpu/start.S b/arch/riscv/cpu/start.S index
704190f946..e4276e8e19 100644
--- a/arch/riscv/cpu/start.S
+++ b/arch/riscv/cpu/start.S
@@ -38,8 +38,6 @@ _start:
mv s0, a0
mv s1, a1- li t0, CONFIG_SYS_SDRAM_BASE
- SREG a2, 0(t0)
la t0, trap_entry
#ifdef CONFIG_RISCV_SMODE
csrw stvec, t0
--This is weird. I remember these two lines were already removed by
Lukas's patch series before? Did not have time to dig out the history
though.Regards,
BinYou are correct, however I removed it again, because I did not want to break
Rick's board. He did add a commit to the last pull request that removes these
two lines and adjusts his board accordingly, but it is not in the current one.Hi Likas
Thanks for your explanation.
RIck's commit as below
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlWhen we run U-Boot in S-mode the BBL runs from 0x80000000 so this
two lines corrupts BBL instructions.If this is important for some board then please have it around #ifdef.
Hi Anup
In the discussion as below :
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlI try to solve this issue with the aptch
[PATCH] riscv: ax25-ae350: Pass dtb address to u-boot with a1 register
diff --git a/arch/riscv/cpu/start.S b/arch/riscv/cpu/start.S
- li t0, CONFIG_SYS_SDRAM_BASE
- SREG a2, 0(t0)diff --git a/board/AndesTech/ax25-ae350/ax25-ae350.c
b/board/AndesTech/ax25-ae350/ax25-ae350.c
void *board_fdt_blob_setup(void)
{
- void **ptr = (void *)CONFIG_SYS_SDRAM_BASE;
+ void **ptr = (void *)&prior_stage_fdt_address;in the previous pull request.
But Bin do not agree with that I use prior_stage_fdt_address in
board_fdt_blob_setup( )
I try to explain why I use it like that way.
Then Bin have not any reply in the following mail.
Finally I decide to drop this patch in the next pull request.Hi Bin
How do you think about I recovery this patch to fix this issue ?
Actually, previous booting stage can pass location of FDT stored in flash
to U-Boot. U-Boot requires FDT at a DRAM location which it can modify
in-place before passing on to Linux kernel so we should relocate the FDT
passed by previous booting stage to some board specific DRAM location.My suggestion is as follows:
Instead of SDRAM_BASE, we can have new board specific config
CONFIG_RISCV_PRIOR_FDT_BASEIf CONFIG_RISCV_PRIOR_FDT_BASE is defined/selected by
config then in start.S copy-over the FDT from location pointed by
"a1" register to location pointed by CONFIG_RISCV_PRIOR_FDT_BASE.Hi Anup
It can not achieve dtb delivery at runtime.
Can you elaborate why?
CONFIG_RISCV_PRIOR_FDT_BASE is determined at compile time.
I am wondering how it can be modified at run time ?I think you miss-understood my suggestion. I did not meant changing
CONFIG_RISCV_PRIOR_FDT_BASEat runtime.Quoted 2 lines
Quoted 9 lines
Quoted 3 lines
I am sure we can always relocate FDT passed by previous stage to some safer location and use it from there.
My original patch also can achieve that dtb passed by a1 and relocated and boot.
Great !!!
Why not update your original patch to relocate FDT and use FDT from safer location?
Good question.
Above can see the question I ask for Bin :
How do you think about I recovery this patch to fix this issue ?Quoted 9 lines
Quoted 5 lines
Quoted 1 line
Before you talking about
CONFIG_RISCV_PRIOR_FDT_BASE!Can you explain why you need
CONFIG_OF_BOARD?
Why can you not useCONFIG_OF_PRIOR_STAGE?You can find the discussion as below:
https://patchwork.ozlabs.org/patch/988884/If I understand correctly, so far we have two scenarios to support:
Quoted 8 lines
1. U-Boot is booting directly from reset vector from ROM. This canonical way to support DT is via
CONFIG_OF_EMBEDorCONFIG_OF_SEPARATE. In such configuration, there is no any previous bootloader so the concept ofCONFIG_OF_PRIOR_STAGEdoes not apply.2. U-Boot is booting from previous bootloader, and DT is passed in a1 register. Such configuration we can use
CONFIG_OF_PRIOR_STAGE.Quoted 8 lines
I use the 3rd way,
CONFIG_OF_BOARD.
It can be found in README.
And can be chosen by make menuconfigIt is the most flexible way that I can implement my own
board_fdt_blob_setup( )which can both support boot from RAM or ROM without any configuration change. I will indeed useCONFIG_OF_EMBEDwhen u-boot is in debug stage.Quoted 5 lines
What I don't understand is that if U-Boot is booting directly from the reset vector, there is no a1 passed by anyone. U-Boot itself should figure out a way to determine the DT and that's how
CONFIG_OF_EMBEDorCONFIG_OF_SEPARATEis doing. Can you elaborate this configuration?I use
CONFIG_OF_BOARDandboard_fdt_blob_setupas below:void
*board_fdt_blob_setup(void)
{
void **ptr = (void *)CONFIG_SYS_SDRAM_BASE;
if (fdt_magic(*ptr)==FDT_MAGIC)
return (void *)*ptr;return (void *)CONFIG_SYS_FDT_BASE;
}1. When booting from RAM
a1 can be passed by loader and reserved inCONFIG_SYS_SDRAM_BASE
temporarily.2. When booting from FLASH
a1 can NOT be passed by loader and reserved inCONFIG_SYS_SDRAM_BASEtemporarily.Quoted 8 lines
So dtb shall be get from
CONFIG_SYS_FDT_BASE(flash base) which
the dtb shall be pre-burned in this flash space..
OrCONFIG_SYS_FDT_BASEmaybe a memory map space (NOT RAM or ROM)
provided by HW.That is why I mean using
CONFIG_OF_BOARDcan support both boot from ram or rom with one configuration.Quoted 7 lines
Thanks for the info. So with the latest info, I now understand you wanted to use
CONFIG_OF_BOARDto support both configurations. That makes sense to me, however I still wanted to point out the canonical way to support booting from ROM is viaCONFIG_OF_SEPARATEorCONFIG_OF_EMBED. Since your board can support booting from reset vector directly, what's the need to support the booting from RAM configuration?I will develop u-boot via booting from ram. It will easy for debugging. After develop complete.
It will be good for demo via booting from flash.
With one configuration, it can decrease to make mistake with wrong configuration between 2 configuration
for ram or rom individually.In that configuration, what is the first stage
Quoted 1 line
bootloader?
Quoted 8 lines
Quoted 4 lines
When booting from ram
GDB will be the first stage to load u-boot.
So it is not good for demo, because it need a pc to fire gdb.OK, thanks for the info. For this patch, let's go with your proposal then, but please add some comments in the codes there for people to understand later.
Hi Bin
You say go with your proposal :
Does that mean you agree with the following modification ?arch/riscv/cpu/start.S(quoted diff) +0
-2- li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0)
board/AndesTech/ax25-ae350/ax25-ae350.c
void*board_fdt_blob_setup(void)
{(quoted diff) +1
-1- void **ptr = (void *)CONFIG_SYS_SDRAM_BASE; + void **ptr = (void *)&prior_stage_fdt_address;
Quoted 2 lines
And add some comments in this patch for people to understand it.
This one.
Quoted 5 lines
Or
I still can NOT borrowprior_stage_fdt_addressand shall find another way to overcome the problem
after remove the two line instart.S?
Regards,
Bin
PATCH v5 4/4 riscv: Remove redundant a2 store on DRAM base in start.S
Bin Meng <[email protected]> 於 2018年11月30日 週五 下午3:26寫道:
Quoted 286 lines
Hi Rick,
Quoted 282 lines · Rick Chen
Bin Meng <[email protected]> 於 2018年11月30日 週五 下午2:57寫道:
Quoted 257 lines
Hi Rick,
Quoted 253 lines · Rick Chen
Bin Meng <[email protected]> 於 2018年11月30日 週五 下午2:21寫道:
Quoted 233 lines
Hi Rick,
Quoted 220 lines · Rick Chen
Bin Meng <[email protected]> 於 2018年11月30日 週五 上午9:48寫道:
Quoted 193 lines
Hi Rick,
Quoted 180 lines · Rick Chen
Bin Meng <[email protected]> 於 2018年11月27日 週二 下午6:07寫道:
Quoted 169 lines
Hi Rick,
Quoted 153 lines · Rick Chen
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午3:56寫道:
Quoted 151 lines · Rick Chen
Quoted 149 lines
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午2:40寫道:
Quoted 142 lines · Rick Chen
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午2:14寫道:
On Tue, 27 Nov, 2018, 11:38 AM Rick Chen <[email protected] wrote:
Anup Patel <[email protected]> 於 2018年11月27日 週二 下午1:47寫道:
On Tue, Nov 27, 2018 at 11:14 AM Anup Patel <[email protected]> wrote:
On Tue, Nov 27, 2018 at 10:50 AM Rick Chen <[email protected]> wrote:
Anup Patel <[email protected]> 於 2018年11月27日 週二 上午11:28寫道:
On Tue, Nov 27, 2018 at 8:50 AM Rick Chen <[email protected]> wrote:
Currently, the RISC-V U-Boot is saving a2 register at
CONFIG_SYS_DRAM_BASE in start.S which does not make sense because
there is no information passed by previous booting stage in a2
register.This patch removes redundant a2 store on DRAM base.
Signed-off-by: Anup Patel <[email protected]>
---
arch/riscv/cpu/start.S | 2 --
1 file changed, 2 deletions(-)diff --git a/arch/riscv/cpu/start.S b/arch/riscv/cpu/start.S index
704190f946..e4276e8e19 100644
--- a/arch/riscv/cpu/start.S
+++ b/arch/riscv/cpu/start.S
@@ -38,8 +38,6 @@ _start:
mv s0, a0
mv s1, a1- li t0, CONFIG_SYS_SDRAM_BASE
- SREG a2, 0(t0)
la t0, trap_entry
#ifdef CONFIG_RISCV_SMODE
csrw stvec, t0
--This is weird. I remember these two lines were already removed by
Lukas's patch series before? Did not have time to dig out the history
though.Regards,
BinYou are correct, however I removed it again, because I did not want to break
Rick's board. He did add a commit to the last pull request that removes these
two lines and adjusts his board accordingly, but it is not in the current one.Hi Likas
Thanks for your explanation.
RIck's commit as below
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlWhen we run U-Boot in S-mode the BBL runs from 0x80000000 so this
two lines corrupts BBL instructions.If this is important for some board then please have it around #ifdef.
Hi Anup
In the discussion as below :
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlI try to solve this issue with the aptch
[PATCH] riscv: ax25-ae350: Pass dtb address to u-boot with a1 register
diff --git a/arch/riscv/cpu/start.S b/arch/riscv/cpu/start.S
- li t0, CONFIG_SYS_SDRAM_BASE
- SREG a2, 0(t0)diff --git a/board/AndesTech/ax25-ae350/ax25-ae350.c
b/board/AndesTech/ax25-ae350/ax25-ae350.c
void *board_fdt_blob_setup(void)
{
- void **ptr = (void *)CONFIG_SYS_SDRAM_BASE;
+ void **ptr = (void *)&prior_stage_fdt_address;in the previous pull request.
But Bin do not agree with that I use prior_stage_fdt_address in
board_fdt_blob_setup( )
I try to explain why I use it like that way.
Then Bin have not any reply in the following mail.
Finally I decide to drop this patch in the next pull request.Hi Bin
How do you think about I recovery this patch to fix this issue ?
Actually, previous booting stage can pass location of FDT stored in flash
to U-Boot. U-Boot requires FDT at a DRAM location which it can modify
in-place before passing on to Linux kernel so we should relocate the FDT
passed by previous booting stage to some board specific DRAM location.My suggestion is as follows:
Instead of SDRAM_BASE, we can have new board specific config
CONFIG_RISCV_PRIOR_FDT_BASEIf CONFIG_RISCV_PRIOR_FDT_BASE is defined/selected by
config then in start.S copy-over the FDT from location pointed by
"a1" register to location pointed by CONFIG_RISCV_PRIOR_FDT_BASE.Hi Anup
It can not achieve dtb delivery at runtime.
Can you elaborate why?
CONFIG_RISCV_PRIOR_FDT_BASE is determined at compile time.
I am wondering how it can be modified at run time ?I think you miss-understood my suggestion. I did not meant changing
CONFIG_RISCV_PRIOR_FDT_BASE at runtime.I am sure we can always relocate FDT passed by previous stage to some safer location and use it from there.
My original patch also can achieve that dtb passed by a1 and relocated and boot.
Great !!!
Why not update your original patch to relocate FDT and use FDT from
safer location?Good question.
Above can see the question I ask for Bin :
How do you think about I recovery this patch to fix this issue ?Quoted 9 lines
Quoted 5 lines
Quoted 1 line
Before you talking about
CONFIG_RISCV_PRIOR_FDT_BASE!Can you explain why you need
CONFIG_OF_BOARD?
Why can you not useCONFIG_OF_PRIOR_STAGE?You can find the discussion as below:
https://patchwork.ozlabs.org/patch/988884/If I understand correctly, so far we have two scenarios to support:
Quoted 8 lines
1. U-Boot is booting directly from reset vector from ROM. This canonical way to support DT is via
CONFIG_OF_EMBEDorCONFIG_OF_SEPARATE. In such configuration, there is no any previous bootloader so the concept ofCONFIG_OF_PRIOR_STAGEdoes not apply.2. U-Boot is booting from previous bootloader, and DT is passed in a1 register. Such configuration we can use
CONFIG_OF_PRIOR_STAGE.Quoted 8 lines
I use the 3rd way,
CONFIG_OF_BOARD.
It can be found in README.
And can be chosen by make menuconfigIt is the most flexible way that I can implement my own
board_fdt_blob_setup( )which can both support boot from RAM or ROM without any configuration change. I will indeed useCONFIG_OF_EMBEDwhen u-boot is in debug stage.Quoted 5 lines
What I don't understand is that if U-Boot is booting directly from the reset vector, there is no a1 passed by anyone. U-Boot itself should figure out a way to determine the DT and that's how
CONFIG_OF_EMBEDorCONFIG_OF_SEPARATEis doing. Can you elaborate this configuration?I use
CONFIG_OF_BOARDandboard_fdt_blob_setupas below:void
*board_fdt_blob_setup(void)
{
void **ptr = (void *)CONFIG_SYS_SDRAM_BASE;
if (fdt_magic(*ptr)==FDT_MAGIC)
return (void *)*ptr;return (void *)CONFIG_SYS_FDT_BASE;
}1. When booting from RAM
a1 can be passed by loader and reserved inCONFIG_SYS_SDRAM_BASE
temporarily.2. When booting from FLASH
a1 can NOT be passed by loader and reserved inCONFIG_SYS_SDRAM_BASEtemporarily.Quoted 8 lines
So dtb shall be get from
CONFIG_SYS_FDT_BASE(flash base) which
the dtb shall be pre-burned in this flash space..
OrCONFIG_SYS_FDT_BASEmaybe a memory map space (NOT RAM or ROM)
provided by HW.That is why I mean using
CONFIG_OF_BOARDcan support both boot from ram or rom with one configuration.Quoted 7 lines
Thanks for the info. So with the latest info, I now understand you wanted to use
CONFIG_OF_BOARDto support both configurations. That makes sense to me, however I still wanted to point out the canonical way to support booting from ROM is viaCONFIG_OF_SEPARATEorCONFIG_OF_EMBED. Since your board can support booting from reset vector directly, what's the need to support the booting from RAM configuration?I will develop u-boot via booting from ram. It will easy for debugging. After develop complete.
It will be good for demo via booting from flash.
With one configuration, it can decrease to make mistake with wrong configuration between 2 configuration
for ram or rom individually.In that configuration, what is the first stage
Quoted 1 line
bootloader?
Quoted 8 lines
Quoted 4 lines
When booting from ram
GDB will be the first stage to load u-boot.
So it is not good for demo, because it need a pc to fire gdb.OK, thanks for the info. For this patch, let's go with your proposal then, but please add some comments in the codes there for people to understand later.
Hi Bin
You say go with your proposal :
Does that mean you agree with the following modification ?arch/riscv/cpu/start.S(quoted diff) +0
-2- li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0)
board/AndesTech/ax25-ae350/ax25-ae350.c
void*board_fdt_blob_setup(void)
{(quoted diff) +1
-1- void **ptr = (void *)CONFIG_SYS_SDRAM_BASE; + void **ptr = (void *)&prior_stage_fdt_address;
Quoted 4 lines
Quoted 2 lines
And add some comments in this patch for people to understand it.
This one.
Hi Bin
Thanks for your opinion. :)
Rick
Quoted 9 lines
Quoted 6 lines
Or
I still can NOT borrowprior_stage_fdt_addressand shall find another way to overcome the problem
after remove the two line instart.S?Regards,
Bin
PATCH v5 4/4 riscv: Remove redundant a2 store on DRAM base in start.S
In reply to Rick ChenQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
When we run U-Boot in S-mode the BBL runs from
0x80000000so this two lines corrupts BBL instructions.
Hi Anup
You said
Your patchset based upon git://git.denx.de/u-boot-riscv.git
Why you announce this problem in [PATCH v5 4/4] riscv: Remove redundant a2 store on DRAM base in start.S
Why you do not find this proble in v1, v2, v3, v4 ?
Rick
Quoted 64 lines
Quoted 39 lines
Quoted 39 lines
Quoted 30 lines
Quoted 3 lines
If this is important for some board then please have it around #ifdef.
Hi Anup
In the discussion as below :
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlI try to solve this issue with the aptch
[PATCH] riscv: ax25-ae350: Pass dtb address to u-boot with a1 registerarch/riscv/cpu/start.S +0
-2- li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0)board/AndesTech/ax25-ae350/ax25-ae350.c +1
-1void *board_fdt_blob_setup (void ) { -void **ptr = (void *)CONFIG_SYS_SDRAM_BASE ; +void **ptr = (void *)&prior_stage_fdt_address;in the previous pull request.
But Bin do not agree with that I use
prior_stage_fdt_addressinboard_fdt_blob_setup( )
I try to explain why I use it like that way.
Then Bin have not any reply in the following mail. Finally I decide to drop this patch in the next pull request.Quoted 3 lines
Hi Bin
How do you think about I recovery this patch to fix this issue ?
Actually, previous booting stage can pass location of FDT stored in flash to U-Boot. U-Boot requires FDT at a DRAM location which it can modify in-place before passing on to Linux kernel so we should relocate the FDT passed by previous booting stage to some board specific DRAM location.
Quoted 9 lines
Quoted 8 lines
My suggestion is as follows:
Instead of
SDRAM_BASE, we can have new board specific configCONFIG_RISCV_PRIOR_FDT_BASEIf
CONFIG_RISCV_PRIOR_FDT_BASEis defined/selected by config then instart.Scopy-over the FDT from location pointed by "a1" register to location pointed byCONFIG_RISCV_PRIOR_FDT_BASE.Hi Anup
It can not achieve dtb delivery at runtime.
Rick
Quoted 9 lines
I think you can copy-over FDT in C code too. You don't need to do in
start.S.Quoted 6 lines
In your
board_fdt_blob_setup(), you can safely do:
void **ptr = (void *)CONFIG_RISCV_PRIOR_FDT_BASE;Regards,
Anup
PATCH v5 4/4 riscv: Remove redundant a2 store on DRAM base in start.S
Quoted 4 lines · Rick Chen
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
When we run U-Boot in S-mode the BBL runs from
0x80000000so this two lines corrupts BBL instructions.
Quoted 8 lines
Hi Anup
You said
Your patchset based upongit://git.denx.de/u-boot-riscv.gitWhy you announce this problem in [PATCH v5 4/4] riscv: Remove redundant a2 store on DRAM base in
start.S
Why you do not find this proble in v1, v2, v3, v4 ?
I had this change locally. I thought some would definitely remove this lines but did not see that happening so I send patch to remove these lines myself.
Regards,
Anup
PATCH v5 4/4 riscv: Remove redundant a2 store on DRAM base in start.S
In reply to Rick ChenHi Rick,
Quoted 84 lines · Rick Chen
Anup Patel <[email protected]> 於 2018年11月27日 週二 上午11:28寫道:
Quoted 47 lines · Rick Chen
Quoted 45 lines
Quoted 33 lines
Quoted 32 lines
Quoted 32 lines
Quoted 18 lines
Currently, the RISC-V U-Boot is saving a2 register at
CONFIG_SYS_DRAM_BASEinstart.Swhich does not make sense because there is no information passed by previous booting stage in a2 register.This patch removes redundant a2 store on DRAM base.
Signed-off-by Anup Patel <[email protected]>--- arch/riscv/cpu/start.S | 2 -- 1 file changed, 2 deletions(-)arch/riscv/cpu/start.S index renamed from arch/riscv/cpu/start.S +0
-0
704190f946..e4276e8e19100644arch/riscv/cpu/start.S _start:
Quoted 9 lines
arch/riscv/cpu/start.S +0
-3@@ -38,8 +38,6 @@ _start: mv s0, a0 mv s1, a1 - li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0) la t0, trap_entry #ifdef CONFIG_RISCV_SMODE csrw stvec, t0 --This is weird. I remember these two lines were already removed by Lukas's patch series before? Did not have time to dig out the history though.
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Regards,
BinYou are correct, however I removed it again, because I did not want to break Rick's board. He did add a commit to the last pull request that removes these two lines and adjusts his board accordingly, but it is not in the current one.
Hi Likas
Thanks for your explanation.
Quoted 8 lines
Quoted 2 lines
RIck's commit as below
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlWhen we run U-Boot in S-mode the BBL runs from
0x80000000so this two lines corrupts BBL instructions.If this is important for some board then please have it around #ifdef.
Hi Anup
In the discussion as below :
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlI try to solve this issue with the aptch
[PATCH] riscv: ax25-ae350: Pass dtb address to u-boot with a1 registerarch/riscv/cpu/start.S +0
-2- li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0)board/AndesTech/ax25-ae350/ax25-ae350.c +1
-1void *board_fdt_blob_setup (void ) { -void **ptr = (void *)CONFIG_SYS_SDRAM_BASE ; +void **ptr = (void *)&prior_stage_fdt_address;in the previous pull request.
But Bin do not agree with that I use
prior_stage_fdt_addressinboard_fdt_blob_setup( )
I try to explain why I use it like that way.
Then Bin have not any reply in the following mail. Finally I decide to drop this patch in the next pull request.
Quoted 4 lines
Hi Bin
How do you think about I recovery this patch to fix this issue ?
Do you mean removing the two lines in start.S? Yes, let's do this. However for the ax25-ae350 board, in order to support booting from NOR, we should introduce CONFIG_OF_EMBED or CONFIG_OF_SEPARATE, and leave prior_stage_fdt_address support only for cases which U-Boot is loaded by previous stage bootloaders.
Regards,
Bin
PATCH v5 4/4 riscv: Remove redundant a2 store on DRAM base in start.S
In reply to Anup PatelQuoted 47 lines · Anup Patel
Quoted 45 lines · Rick Chen
Quoted 33 lines
Quoted 32 lines
Quoted 32 lines
Quoted 18 lines
Currently, the RISC-V U-Boot is saving a2 register at
CONFIG_SYS_DRAM_BASEinstart.Swhich does not make sense because there is no information passed by previous booting stage in a2 register.This patch removes redundant a2 store on DRAM base.
Signed-off-by Anup Patel <[email protected]>--- arch/riscv/cpu/start.S | 2 -- 1 file changed, 2 deletions(-)arch/riscv/cpu/start.S index renamed from arch/riscv/cpu/start.S +0
-0
704190f946..e4276e8e19100644arch/riscv/cpu/start.S _start:
Quoted 9 lines
arch/riscv/cpu/start.S +0
-3@@ -38,8 +38,6 @@ _start: mv s0, a0 mv s1, a1 - li t0, CONFIG_SYS_SDRAM_BASE - SREG a2, 0(t0) la t0, trap_entry #ifdef CONFIG_RISCV_SMODE csrw stvec, t0 --This is weird. I remember these two lines were already removed by Lukas's patch series before? Did not have time to dig out the history though.
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Regards,
BinYou are correct, however I removed it again, because I did not want to break Rick's board. He did add a commit to the last pull request that removes these two lines and adjusts his board accordingly, but it is not in the current one.
Hi Likas
Thanks for your explanation.
Quoted 8 lines
Quoted 2 lines
RIck's commit as below
https://www.mail-archive.com/u-boot at lists.denx.de/msg305880.htmlWhen we run U-Boot in S-mode the BBL runs from
0x80000000so this two lines corrupts BBL instructions.If this is important for some board then please have it around #ifdef.
Please don't do any #ifdef here. That codes should be removed, and we should figure out a way that does not break the ax25-ae350 board.
Quoted 1 line
My apologies for the noise.
Regards,
Bin
v5 cover RISC-V S-mode support
In reply to Anup PatelQuoted 69 lines · Anup Patel
This patchset allows us runing u-boot in S-mode which is useful on platforms where M-mode runtime firmware is an independent firmware and u-boot is used as last stage OS bootloader.
The patchset based upon
git://git.denx.de/u-boot-riscv.git
and is tested on QEMU in both M-mode and S-mode.For S-mode testing, we have used u-boot.bin as payload of latest BBL (at commit
6ebd0f2a46255d0c76dad3c05b16c1d154795d26) applied with following changes:machine/emulation.c +6
-0@@ -162,6 +162,12 @@ static inline int emulate_read_csr(int num, uintptr_t mstatus, uintptr_t* resultswitch (num) { +case CSR_MISA : + *result =read_csr (misa); +return 0 ; +case CSR_MHARTID : + *result =read_csr (mhartid); +return 0 ;case CSR_CYCLE :if (!((counteren >> (CSR_CYCLE -CSR_CYCLE )) &1 ))return -1 ;Changes since v4:
- Rebased series based on commit52923c6db7f00e0197ec894c8c1bb8a7681974bbofgit://git.denx.de/u-boot-riscv.git
- Added a patch to remove redundant a2 store on DRAM base. This store was creating problem booting U-Boot in S-mode using BBL.Changes since v3:
- Replaced 'u-boot' with 'U-Boot' in commit message
- Dropped 'an' inRISCV_SMODEkconfig option help message
- Added appropriate #ifdef inarch/riscv/lib/interrupts.cChanges since v2:
- Dropped 'default n" fromRISCV_SMODEkconfig option
- Replaced '-smode_' in defconfig names with '_smode_'Changes since v1:
- Rebased upon latestgit://git.denx.de/u-boot-riscv.git
- Add details in cover letter for running u-boot in S-mode using BBLAnup Patel (4):
riscv: Add kconfig option to run U-Boot in S-mode
riscv: qemu: Use differentSYS_TEXT_BASEfor S-mode
riscv: Add S-mode defconfigs for QEMU virt machine
riscv: Remove redundant a2 store on DRAM base instart.Sarch/riscv/Kconfig | 5 ++++ arch/riscv/cpu/start.S | 35 +++++++++++++++++++++++-- arch/riscv/include/asm/encoding.h | 2 ++ arch/riscv/lib/interrupts.c | 36 +++++++++++++++++++------- board/emulation/qemu-riscv/Kconfig | 3 ++- board/emulation/qemu-riscv/MAINTAINERS | 2 ++ configs/qemu-riscv32_smode_defconfig | 10 +++++++ configs/qemu-riscv64_smode_defconfig | 11 ++++++++ 8 files changed, 92 insertions(+), 12 deletions(-) create mode 100644 configs/qemu-riscv32_smode_defconfig create mode 100644 configs/qemu-riscv64_smode_defconfig
Quoted 3 lines
--
2.17.1
Hi Rick,
If its fine with you then please take PATCH 1-to-3
The PATCH 4 "riscv: Remove redundant a2 store on DRAM base in start.S" you can drop and merge a better solution at your end.
Regards,
Anup