-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
soc: riscv: andes_v5: update ae350 soc #59813
soc: riscv: andes_v5: update ae350 soc #59813
Conversation
e942f6b
to
b71ee0f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are the changes in this file valid in general for all the RISCV boards or just for Andes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The difference between RISC-V generic linker.ld and ae350 linker.ld is as follows:
- apply MPU_ALIGN to __rom_region_start and __rom_region_end (for XIP only).
- redefine MPU_ALIGN to match the granularity of PMA
I think (1) applies to all RISC-V boards, while (2) is specific to Andes boards.
@@ -28,6 +28,12 @@ config RV32I_CPU | |||
select RISCV_ISA_EXT_ZICSR | |||
select RISCV_ISA_EXT_ZIFENCEI | |||
|
|||
config RV32E_CPU |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have CONFIG_RISCV_ISA_RV32E
, why this is needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AE350 is FPGA based platform and we want RV32E can be selected by
menuconfig or board_defconfig for AE350 bitstream integrate with RV32E core.
/* Memory barrier, flush all I/D-Cache before setting L2C */ | ||
__asm__ volatile ("fence.i"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the newly introduced barrier API for this. See include/zephyr/sys/barrier.h
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Andes core needs to execute fence.i to flush all I/D cache before updating the L2 cache function.
The barrier API in RISC-V seems only support fence instruction.
Maybe I can modify the comment to avoid confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right but why you cannot use fence
here instead of fence.i
? AFAIK fence
should be just a bit more restrictive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Andes core, fence
instruction is used to order device I/O and memory accesses as viewed by other RISC-V harts and external devices, but it does not perform any operation on the local I/D cache.
fence.i
is used to synchronizing the L1 and L2 cache due to the hardware limitation of Andes L2 cache.
# HW DSP options | ||
#CONFIG_SOC_ANDES_V5_HWDSP=y | ||
|
||
# EXEC.IT options | ||
#CONFIG_SOC_ANDES_V5_EXECIT=y |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this commented out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only Andes toolchain support this option, disable this option for zephyr-sdk.
# Cache options | ||
CONFIG_CACHE_ENABLE=y | ||
|
||
# Nocache memory options | ||
#CONFIG_SOC_ANDES_V5_PMA=y | ||
#CONFIG_NOCACHE_MEMORY=y | ||
|
||
# I/O Coherence Port options | ||
#CONFIG_SOC_ANDES_V5_IOCP=y |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not all of AE350 bitstream support IOCP, disable this option for various AE350 bitstream compatible.
case 15: | ||
write_csr(NDS_PMAADDR15, value); break; | ||
csr_write(NDS_PMAADDR15, value); break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a lot of repeated code. Can you generate it with FOR_EACH
helper macro?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice suggestion, fixed it, thank you.
case 3: | ||
read_csr(pmacfg, NDS_PMACFG3); break; | ||
pmacfg = csr_read(NDS_PMACFG3); break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto - FOR_EACH
could help reduce the repeated code.
case 3: | ||
write_csr(NDS_PMACFG3, pmacfg); break; | ||
csr_write(NDS_PMACFG3, pmacfg); break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto - FOR_EACH
could help reduce the repeated code.
Fix mtimer lack of interrupts-extended and make syscon compatilbe to atcsmu100. Signed-off-by: Jimmy Zheng <[email protected]>
Synchronize ae350 linker.ld with riscv generic linker.ld and workaround kernel object address may be 0x0 in XIP system. Signed-off-by: Jimmy Zheng <[email protected]>
Refine PMA driver and define MPU_ALIGN() to PMA granularity in RAM_SECTIONS, otherwise MPU_ALIGN() is defined to PMP granularity. Signed-off-by: Jimmy Zheng <[email protected]>
Enable PMP and set PMP granularity to 8 for most of ae350 bitstream. This commit also make MPU_ALIGN() apply to __rom_region_end in XIP system. Signed-off-by: Jimmy Zheng <[email protected]>
Enable RISC-V C extension for Andes core. Signed-off-by: Jimmy Zheng <[email protected]>
Add CONFIG_RV32E_CPU for AE350 platform integrated with Andes RV32E core, such as N22, D23 core. Signed-off-by: Jimmy Zheng <[email protected]>
Andes EXEC.IT (Execution on Instruction Table) is supported by Andes toolchain only. Andes toolchain will replaces suitable 32-bit instructions with the 16-bit "exec.it <INDEX>" in which <INDEX> points to a corresponding 32-bit instruction in look up table. Signed-off-by: Jimmy Zheng <[email protected]>
Refine source code and flush all I/D-Cache before update L2 cache register. Signed-off-by: Jimmy Zheng <[email protected]>
Add CONFIG_SOC_ANDES_V5_IOCP to indicate Andes I/O Coherence Port handle cache coherency between cache and external non-caching master, such as DMA controller. Signed-off-by: Jimmy Zheng <[email protected]>
Enlarge TEST_EXTRA_STACK_SIZE for AE350 RV64 bitstream. Signed-off-by: Jimmy Zheng <[email protected]>
Exclude adp_xc7k_ae350 because Andes core doesn't support RISC-V vectored mode from csr $mtvec. Signed-off-by: Jimmy Zheng <[email protected]>
Replace redundant CONFIG_CACHE_ENABLE by generic Kconfig CONFIG_ICACHE, CONFIG_DCACHE. Signed-off-by: Jimmy Zheng <[email protected]>
Based on the conversation in #59041, I have removed the redundant Kconfig CONFIG_CACHE_ENABLE, thank you @carlocaione for your comment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general LGTM. I cannot vouch for the soc-specific changes but being self-contained in the soc/board directories I'm ok with that.
This PR refines ae350 porting and adds some Andes features below.
Refine exist code:
Enable RISC-V feature on AE350:
Add Andes feature:
EXEC.IT is supported by Andes V5 toolchain which generates a look-up table and replaces suitable 32-bit instructions with the 16-bit exec.it instruction to decrease code size.
IOCP handle cache coherency between cache and external non-caching master, such DMA controller.