From 0540056eaa56fbb841420adbe37f1ad72101a8f6 Mon Sep 17 00:00:00 2001 From: Germain Haugou Date: Thu, 6 Feb 2020 13:26:14 +0100 Subject: [PATCH 01/12] Few fixes to have riscv-tests/testIRQ working on pulpissimo --- include/archi/chips/marsellus/properties.h | 1 + include/archi/chips/pulp/properties.h | 1 + include/archi/chips/pulpissimo/properties.h | 1 + include/hal/timer/timer_v2.h | 8 ++++++++ include/implem/irq.h | 14 +++++++------- include/pulp.h | 15 +++++++++++++++ kernel/crt0.S | 4 ++-- kernel/fll-v1.c | 6 +++--- kernel/irq.c | 11 ++++++----- 9 files changed, 44 insertions(+), 17 deletions(-) diff --git a/include/archi/chips/marsellus/properties.h b/include/archi/chips/marsellus/properties.h index 9c14167..248321d 100644 --- a/include/archi/chips/marsellus/properties.h +++ b/include/archi/chips/marsellus/properties.h @@ -98,6 +98,7 @@ #define ARCHI_FC_CID 31 #define ARCHI_HAS_FC_ITC 1 #define ARCHI_HAS_FC 1 +#define ARCHI_CORE_HAS_1_10 1 /* diff --git a/include/archi/chips/pulp/properties.h b/include/archi/chips/pulp/properties.h index 35bcb96..0cbccff 100644 --- a/include/archi/chips/pulp/properties.h +++ b/include/archi/chips/pulp/properties.h @@ -99,6 +99,7 @@ #define ARCHI_FC_CID 31 #define ARCHI_HAS_FC_ITC 1 #define ARCHI_HAS_FC 1 +#define ARCHI_CORE_HAS_1_10 1 #endif diff --git a/include/archi/chips/pulpissimo/properties.h b/include/archi/chips/pulpissimo/properties.h index 9b9360d..51bd2b7 100644 --- a/include/archi/chips/pulpissimo/properties.h +++ b/include/archi/chips/pulpissimo/properties.h @@ -78,6 +78,7 @@ #define ARCHI_FC_CID 31 #define ARCHI_HAS_FC_ITC 1 #define ARCHI_HAS_FC 1 +#define ARCHI_CORE_HAS_1_10 1 diff --git a/include/hal/timer/timer_v2.h b/include/hal/timer/timer_v2.h index 2eb5802..d6923f1 100644 --- a/include/hal/timer/timer_v2.h +++ b/include/hal/timer/timer_v2.h @@ -42,6 +42,14 @@ static inline unsigned int timer_base_cl(int cid, int id, int sub_id) return ARCHI_CLUSTER_PERIPHERALS_GLOBAL_ADDR(0) + ARCHI_TIMER_OFFSET + id * ARCHI_TIMER_SIZE + sub_id * 4; } +#else + +static inline unsigned int timer_base_cl(int cid, int id, int sub_id) +{ + return 0; +} + + #endif diff --git a/include/implem/irq.h b/include/implem/irq.h index 326dfe9..575f691 100644 --- a/include/implem/irq.h +++ b/include/implem/irq.h @@ -23,11 +23,11 @@ void pos_irq_init(); -void pos_irq_set_handler(int irq, void (*handler)()); +void rt_irq_set_handler(int irq, void (*handler)()); -static inline void pos_irq_mask_set(unsigned int mask) +static inline void rt_irq_mask_set(unsigned int mask) { #if defined(__RISCV_GENERIC__) // Generic riscv case, e.g. Ibex @@ -58,7 +58,7 @@ static inline void pos_irq_mask_set(unsigned int mask) -static inline void pos_irq_mask_clr(unsigned int mask) +static inline void rt_irq_mask_clr(unsigned int mask) { #if defined(__RISCV_GENERIC__) hal_spr_read_then_clr_from_reg(0x304, mask); @@ -82,7 +82,7 @@ static inline void pos_irq_mask_clr(unsigned int mask) -static inline void pos_irq_clr(unsigned int mask) +static inline void rt_irq_clr(unsigned int mask) { #if defined(__RISCV_GENERIC__) // TODO @@ -101,7 +101,7 @@ static inline void pos_irq_clr(unsigned int mask) #endif } -static inline unsigned int pos_irq_get_fc_vector_base() +static inline unsigned int rt_irq_get_fc_vector_base() { if (hal_is_fc()) { @@ -129,7 +129,7 @@ static inline unsigned int pos_irq_get_fc_vector_base() -static inline void pos_irq_set_fc_vector_base(unsigned int base) +static inline void rt_irq_set_fc_vector_base(unsigned int base) { if (hal_is_fc()) { @@ -154,7 +154,7 @@ static inline void pos_irq_set_fc_vector_base(unsigned int base) } -static inline void pos_irq_wait_for_interrupt() +static inline void rt_irq_wait_for_interrupt() { #if !defined(ARCHI_HAS_FC) || defined(ARCHI_HAS_FC_EU) eu_evt_wait(); diff --git a/include/pulp.h b/include/pulp.h index a3b8038..0b73277 100755 --- a/include/pulp.h +++ b/include/pulp.h @@ -34,12 +34,27 @@ typedef enum { PI_FREQ_DOMAIN_PERIPH = 2 } pi_freq_domain_e; +#ifdef ARCHI_HAS_CLUSTER + void cluster_start(int cid, int (*entry)()); void cluster_entry_stub(); int cluster_wait(int cid); +#else + +static inline void cluster_start(int cid, int (*entry)()) +{ +} + +static inline int cluster_wait(int cid) +{ + return 0; +} + +#endif + void _start(); #include diff --git a/kernel/crt0.S b/kernel/crt0.S index 50c2e65..e003faf 100644 --- a/kernel/crt0.S +++ b/kernel/crt0.S @@ -89,7 +89,7 @@ pos_init_entry: #ifdef ARCHI_CORE_HAS_1_10 - j pos_illegal_instr + j __rt_handle_illegal_instr #else j pos_no_irq_handler #endif @@ -134,7 +134,7 @@ _start: pos_illegal_instr: - j pos_irq_illegal_instr + j __rt_handle_illegal_instr pos_no_irq_handler: mret diff --git a/kernel/fll-v1.c b/kernel/fll-v1.c index f91ba81..0b0a858 100644 --- a/kernel/fll-v1.c +++ b/kernel/fll-v1.c @@ -98,9 +98,9 @@ void pos_freq_wait_convergence(int fll) if ( mult_factor_diff <= tolerance) break; - pos_irq_mask_set(1< Date: Tue, 11 Feb 2020 17:31:11 +0100 Subject: [PATCH 02/12] Fixed IRQ handling on cluster side on pulp-open --- include/implem/irq.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/implem/irq.h b/include/implem/irq.h index 575f691..b630a94 100644 --- a/include/implem/irq.h +++ b/include/implem/irq.h @@ -118,7 +118,9 @@ static inline unsigned int rt_irq_get_fc_vector_base() else { #if defined(ARCHI_HAS_CLUSTER) -#if defined(ARCHI_CLUSTER_CTRL_ADDR) +#if defined(ARCHI_CORE_HAS_1_10) + return __builtin_pulp_spr_read(SR_MTVEC) & ~1; +#elif defined(ARCHI_CLUSTER_CTRL_ADDR) return plp_ctrl_bootaddr_get(); #endif #endif @@ -146,7 +148,9 @@ static inline void rt_irq_set_fc_vector_base(unsigned int base) else { #if defined(ARCHI_HAS_CLUSTER) -#if defined(ARCHI_CLUSTER_CTRL_ADDR) +#if defined(ARCHI_CORE_HAS_1_10) + __builtin_pulp_spr_write(SR_MTVEC, base | 1); +#elif defined(ARCHI_CLUSTER_CTRL_ADDR) plp_ctrl_bootaddr_set(base); #endif #endif From eca64eca67845a80d676e12f902dca88bd7c7cfc Mon Sep 17 00:00:00 2001 From: Germain Haugou Date: Thu, 20 Feb 2020 18:52:47 +0100 Subject: [PATCH 03/12] Added config CONFIG_CL_BOOT to forward the execution to cluster side --- kernel/crt0.S | 25 ++++++++++++++++++++++++- rules/pulpos/default_rules.mk | 4 ++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/kernel/crt0.S b/kernel/crt0.S index e003faf..5e71de9 100644 --- a/kernel/crt0.S +++ b/kernel/crt0.S @@ -33,6 +33,14 @@ pos_init_entry: csrr a0, 0xF14 andi a1, a0, 0x1f srli a0, a0, 5 +#ifdef ARCHI_CL_BOOT + + li a2, ARCHI_FC_CID + beq a0, a2, do_cl_boot + bnez a1, pe_start + +#else + #ifdef ARCHI_FC_CID li a2, ARCHI_FC_CID bne a0, a2, pe_start @@ -41,6 +49,8 @@ pos_init_entry: #endif #endif +#endif + # Clear the bss segment @@ -155,4 +165,17 @@ pe_start: mul x1, x3, a1 add x2, x2, x1 j cluster_entry_stub -#endif \ No newline at end of file +#endif + +do_cl_boot: + li x2, 0x10200000 + li x3, 0x1 + la x4, _start + sw x4, 0x40(x2) + sw x3, 8(x2) + +loop: + li x2, 0x1a109800 + sw x0, 0(x2) + wfi + j loop \ No newline at end of file diff --git a/rules/pulpos/default_rules.mk b/rules/pulpos/default_rules.mk index b3e60bc..b1328cf 100644 --- a/rules/pulpos/default_rules.mk +++ b/rules/pulpos/default_rules.mk @@ -75,6 +75,10 @@ ifdef CONFIG_NO_FC PULP_CFLAGS += -DARCHI_NO_FC=1 endif +ifdef CONFIG_CL_BOOT +PULP_CFLAGS += -DARCHI_CL_BOOT=1 +endif + ifdef CONFIG_IO_UART PULP_CFLAGS += -DCONFIG_IO_UART=$(CONFIG_IO_UART) endif From e58af071ba81f12c3d4e4aa38b057ff9e7c2c870 Mon Sep 17 00:00:00 2001 From: Germain Haugou Date: Thu, 5 Mar 2020 13:21:52 +0100 Subject: [PATCH 04/12] Few fixes for pulpissimo fpga, fll init is now deactivated and uart is selected by default --- kernel/chips/pulp/soc.c | 8 ++++++++ kernel/chips/pulpissimo/soc.c | 8 ++++++++ rules/pulpos/targets/pulp.mk | 5 +++++ rules/pulpos/targets/pulpissimo.mk | 5 +++++ 4 files changed, 26 insertions(+) diff --git a/kernel/chips/pulp/soc.c b/kernel/chips/pulp/soc.c index 1d4b1bb..56ee799 100644 --- a/kernel/chips/pulp/soc.c +++ b/kernel/chips/pulp/soc.c @@ -18,6 +18,8 @@ void pos_soc_init() { +#if __PLATFORM__ != ARCHI_PLATFORM_FPGA + pos_fll_constructor(); pos_freq_domains[PI_FREQ_DOMAIN_FC] = pos_fll_init(POS_FLL_FC); @@ -26,5 +28,11 @@ void pos_soc_init() pos_freq_domains[PI_FREQ_DOMAIN_CL] = pos_fll_init(POS_FLL_CL); + +#else + + pos_freq_domains[PI_FREQ_DOMAIN_CL] = PERIPH_FREQUENCY; + +#endif } diff --git a/kernel/chips/pulpissimo/soc.c b/kernel/chips/pulpissimo/soc.c index b722bab..6cd805a 100644 --- a/kernel/chips/pulpissimo/soc.c +++ b/kernel/chips/pulpissimo/soc.c @@ -18,10 +18,18 @@ void pos_soc_init() { +#if __PLATFORM__ != ARCHI_PLATFORM_FPGA + pos_fll_constructor(); pos_freq_domains[PI_FREQ_DOMAIN_FC] = pos_fll_init(POS_FLL_FC); pos_freq_domains[PI_FREQ_DOMAIN_PERIPH] = pos_fll_init(POS_FLL_PERIPH); + +#else + + pos_freq_domains[PI_FREQ_DOMAIN_CL] = PERIPH_FREQUENCY; + +#endif } diff --git a/rules/pulpos/targets/pulp.mk b/rules/pulpos/targets/pulp.mk index 44b698e..ccab7a4 100644 --- a/rules/pulpos/targets/pulp.mk +++ b/rules/pulpos/targets/pulp.mk @@ -41,4 +41,9 @@ PULP_SRCS += kernel/chips/pulp/soc.c include $(PULPRT_HOME)/rules/pulpos/configs/default.mk + +ifeq '$(platform)' 'fpga' +CONFIG_IO_UART=1 +endif + include $(PULPRT_HOME)/rules/pulpos/default_rules.mk \ No newline at end of file diff --git a/rules/pulpos/targets/pulpissimo.mk b/rules/pulpos/targets/pulpissimo.mk index ba12247..31fa720 100644 --- a/rules/pulpos/targets/pulpissimo.mk +++ b/rules/pulpos/targets/pulpissimo.mk @@ -40,4 +40,9 @@ PULP_SRCS += kernel/chips/pulpissimo/soc.c include $(PULPRT_HOME)/rules/pulpos/configs/default.mk + +ifeq '$(platform)' 'fpga' +CONFIG_IO_UART=1 +endif + include $(PULPRT_HOME)/rules/pulpos/default_rules.mk \ No newline at end of file From ffefb9d3393f443a6ce04fa1ff8631de11f195a6 Mon Sep 17 00:00:00 2001 From: Germain Haugou Date: Thu, 5 Mar 2020 14:18:42 +0100 Subject: [PATCH 05/12] Fix to get source files working with zsh --- configs/common.sh | 8 ++++++++ configs/marsellus.sh | 9 ++++++++- configs/pulp.sh | 9 ++++++++- configs/pulpissimo.sh | 9 ++++++++- 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/configs/common.sh b/configs/common.sh index 30f4b51..2e81460 100644 --- a/configs/common.sh +++ b/configs/common.sh @@ -1,6 +1,14 @@ #!/bin/bash -e +if [ -n "${ZSH_VERSION:-}" ]; then + DIR="$(readlink -f -- "${(%):-%x}")" + DIRNAME="$(dirname $DIR)" + scriptDir="$(dirname $DIRNAME)" +else + scriptDir="$(dirname "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")")" +fi + export PULPRT_HOME=$scriptDir export PULP_SDK_HOME=$PULPRT_HOME \ No newline at end of file diff --git a/configs/marsellus.sh b/configs/marsellus.sh index e9e13e0..06c4c28 100644 --- a/configs/marsellus.sh +++ b/configs/marsellus.sh @@ -3,6 +3,13 @@ export PULPRT_TARGET=marsellus export PULPRUN_TARGET=marsellus -scriptDir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" +if [ -n "${ZSH_VERSION:-}" ]; then + DIR="$(readlink -f -- "${(%):-%x}")" + scriptDir="$(dirname $DIR)" +else + + scriptDir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" + +fi source $scriptDir/common.sh diff --git a/configs/pulp.sh b/configs/pulp.sh index d9c6746..ce3109b 100644 --- a/configs/pulp.sh +++ b/configs/pulp.sh @@ -3,6 +3,13 @@ export PULPRT_TARGET=pulp export PULPRUN_TARGET=pulp -scriptDir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" +if [ -n "${ZSH_VERSION:-}" ]; then + DIR="$(readlink -f -- "${(%):-%x}")" + scriptDir="$(dirname $DIR)" +else + + scriptDir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" + +fi source $scriptDir/common.sh diff --git a/configs/pulpissimo.sh b/configs/pulpissimo.sh index f395853..2882987 100644 --- a/configs/pulpissimo.sh +++ b/configs/pulpissimo.sh @@ -3,6 +3,13 @@ export PULPRT_TARGET=pulpissimo export PULPRUN_TARGET=pulpissimo -scriptDir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" +if [ -n "${ZSH_VERSION:-}" ]; then + DIR="$(readlink -f -- "${(%):-%x}")" + scriptDir="$(dirname $DIR)" +else + + scriptDir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" + +fi source $scriptDir/common.sh From da4157a0e22f9564c29a7594baccd83b556d9297 Mon Sep 17 00:00:00 2001 From: Germain Haugou Date: Thu, 5 Mar 2020 14:28:27 +0100 Subject: [PATCH 06/12] Added possibility to define extra cflags from command-line --- kernel/chips/pulp/soc.c | 2 +- kernel/chips/pulpissimo/soc.c | 4 ++-- rules/pulpos/default_rules.mk | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel/chips/pulp/soc.c b/kernel/chips/pulp/soc.c index 56ee799..0375a6e 100644 --- a/kernel/chips/pulp/soc.c +++ b/kernel/chips/pulp/soc.c @@ -31,7 +31,7 @@ void pos_soc_init() #else - pos_freq_domains[PI_FREQ_DOMAIN_CL] = PERIPH_FREQUENCY; + pos_freq_domains[PI_FREQ_DOMAIN_CL] = ARCHI_FPGA_FREQUENCY; #endif } diff --git a/kernel/chips/pulpissimo/soc.c b/kernel/chips/pulpissimo/soc.c index 6cd805a..b79ecad 100644 --- a/kernel/chips/pulpissimo/soc.c +++ b/kernel/chips/pulpissimo/soc.c @@ -25,10 +25,10 @@ void pos_soc_init() pos_freq_domains[PI_FREQ_DOMAIN_FC] = pos_fll_init(POS_FLL_FC); pos_freq_domains[PI_FREQ_DOMAIN_PERIPH] = pos_fll_init(POS_FLL_PERIPH); - + #else - pos_freq_domains[PI_FREQ_DOMAIN_CL] = PERIPH_FREQUENCY; + pos_freq_domains[PI_FREQ_DOMAIN_CL] = ARCHI_FPGA_FREQUENCY; #endif } diff --git a/rules/pulpos/default_rules.mk b/rules/pulpos/default_rules.mk index b1328cf..654fa33 100644 --- a/rules/pulpos/default_rules.mk +++ b/rules/pulpos/default_rules.mk @@ -38,6 +38,7 @@ VPATH = $(PULPRT_HOME) include $(PULPRT_HOME)/rules/pulpos/src.mk +PULP_CFLAGS += $(PULPRT_CONFIG_CFLAGS) PULP_CFLAGS += -fno-jump-tables -fno-tree-loop-distribute-patterns ifeq '$(CONFIG_LIBC_MINIMAL)' '1' From 280f5755ed79f58597a24d5740dfdec2617502b8 Mon Sep 17 00:00:00 2001 From: Germain Haugou Date: Thu, 5 Mar 2020 15:18:06 +0100 Subject: [PATCH 07/12] Fix for setting frequency on fpga --- drivers/uart.c | 2 +- include/archi/chips/pulp/properties.h | 10 ++++++++++ include/archi/chips/pulpissimo/properties.h | 4 ++++ kernel/chips/pulp/soc.c | 6 +++++- kernel/chips/pulpissimo/soc.c | 4 +++- 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/drivers/uart.c b/drivers/uart.c index 088848c..3459294 100644 --- a/drivers/uart.c +++ b/drivers/uart.c @@ -43,7 +43,7 @@ static void uart_wait_rx_done(int periph) static void uart_setup(int channel, int baudrate) { - int div = (PERIPH_FREQUENCY + baudrate/2) / baudrate; + int div = (pos_freq_domains[PI_FREQ_DOMAIN_PERIPH] + baudrate/2) / baudrate; plp_uart_setup(channel - ARCHI_UDMA_UART_ID(0), 0, div-1); } diff --git a/include/archi/chips/pulp/properties.h b/include/archi/chips/pulp/properties.h index 0cbccff..6e4c292 100644 --- a/include/archi/chips/pulp/properties.h +++ b/include/archi/chips/pulp/properties.h @@ -22,7 +22,17 @@ * FPGA */ +#ifndef ARCHI_FPGA_FREQUENCY #define ARCHI_FPGA_FREQUENCY 5000000 +#endif + +#ifndef ARCHI_FPGA_FC_FREQUENCY +#define ARCHI_FPGA_FC_FREQUENCY 5000000 +#endif + +#ifndef ARCHI_FPGA_CL_FREQUENCY +#define ARCHI_FPGA_CL_FREQUENCY 5000000 +#endif /* * MEMORIES diff --git a/include/archi/chips/pulpissimo/properties.h b/include/archi/chips/pulpissimo/properties.h index 51bd2b7..32465c0 100644 --- a/include/archi/chips/pulpissimo/properties.h +++ b/include/archi/chips/pulpissimo/properties.h @@ -26,6 +26,10 @@ #define ARCHI_FPGA_FREQUENCY 5000000 #endif +#ifndef ARCHI_FPGA_FC_FREQUENCY +#define ARCHI_FPGA_FC_FREQUENCY 5000000 +#endif + /* * MEMORIES diff --git a/kernel/chips/pulp/soc.c b/kernel/chips/pulp/soc.c index 0375a6e..8626f91 100644 --- a/kernel/chips/pulp/soc.c +++ b/kernel/chips/pulp/soc.c @@ -31,7 +31,11 @@ void pos_soc_init() #else - pos_freq_domains[PI_FREQ_DOMAIN_CL] = ARCHI_FPGA_FREQUENCY; + pos_freq_domains[PI_FREQ_DOMAIN_FC] = ARCHI_FPGA_FC_FREQUENCY; + + pos_freq_domains[PI_FREQ_DOMAIN_PERIPH] = ARCHI_FPGA_FREQUENCY; + + pos_freq_domains[PI_FREQ_DOMAIN_CL] = ARCHI_FPGA_CL_FREQUENCY; #endif } diff --git a/kernel/chips/pulpissimo/soc.c b/kernel/chips/pulpissimo/soc.c index b79ecad..1f239ac 100644 --- a/kernel/chips/pulpissimo/soc.c +++ b/kernel/chips/pulpissimo/soc.c @@ -28,7 +28,9 @@ void pos_soc_init() #else - pos_freq_domains[PI_FREQ_DOMAIN_CL] = ARCHI_FPGA_FREQUENCY; + pos_freq_domains[PI_FREQ_DOMAIN_FC] = ARCHI_FPGA_FC_FREQUENCY; + + pos_freq_domains[PI_FREQ_DOMAIN_PERIPH] = ARCHI_FPGA_FREQUENCY; #endif } From 42c768b5235d51b731e522be946212623c1466a8 Mon Sep 17 00:00:00 2001 From: Germain Haugou Date: Thu, 5 Mar 2020 15:56:56 +0100 Subject: [PATCH 08/12] FIxed wrong size of pos_freq_domains --- include/chips/marsellus/config.h | 2 -- include/chips/marsellus/soc.h | 2 +- include/chips/pulp/config.h | 2 -- include/chips/pulp/soc.h | 2 +- include/chips/pulpissimo/config.h | 6 ------ include/chips/pulpissimo/soc.h | 2 +- include/pulp.h | 3 ++- kernel/freq-domains.c | 2 +- 8 files changed, 6 insertions(+), 15 deletions(-) diff --git a/include/chips/marsellus/config.h b/include/chips/marsellus/config.h index 5f6cc76..4ec5d3c 100644 --- a/include/chips/marsellus/config.h +++ b/include/chips/marsellus/config.h @@ -25,6 +25,4 @@ #define PULP_CHIP_STR marsellus #define PULP_CHIP_FAMILY_STR marsellus -#define PERIPH_FREQUENCY 50000000 - #endif diff --git a/include/chips/marsellus/soc.h b/include/chips/marsellus/soc.h index 20814c6..7b67b03 100644 --- a/include/chips/marsellus/soc.h +++ b/include/chips/marsellus/soc.h @@ -22,7 +22,7 @@ #define POS_FLL_PERIPH 1 #define POS_FLL_FC 0 -extern int pos_freq_domains[ARCHI_NB_FLL]; +extern int pos_freq_domains[PI_FREQ_NB_DOMAINS]; void pos_soc_init(); diff --git a/include/chips/pulp/config.h b/include/chips/pulp/config.h index fb7912d..72a0b6a 100644 --- a/include/chips/pulp/config.h +++ b/include/chips/pulp/config.h @@ -25,6 +25,4 @@ #define PULP_CHIP_STR pulp #define PULP_CHIP_FAMILY_STR pulp -#define PERIPH_FREQUENCY 50000000 - #endif diff --git a/include/chips/pulp/soc.h b/include/chips/pulp/soc.h index 65fa71f..7230578 100644 --- a/include/chips/pulp/soc.h +++ b/include/chips/pulp/soc.h @@ -22,7 +22,7 @@ #define POS_FLL_PERIPH 1 #define POS_FLL_FC 0 -extern int pos_freq_domains[ARCHI_NB_FLL]; +extern int pos_freq_domains[PI_FREQ_NB_DOMAINS]; void pos_soc_init(); diff --git a/include/chips/pulpissimo/config.h b/include/chips/pulpissimo/config.h index dc358be..ad61bcd 100644 --- a/include/chips/pulpissimo/config.h +++ b/include/chips/pulpissimo/config.h @@ -25,10 +25,4 @@ #define PULP_CHIP_STR pulpissimo #define PULP_CHIP_FAMILY_STR pulpissimo -#if __PLATFORM__ == ARCHI_PLATFORM_FPGA -#define PERIPH_FREQUENCY 5000000 -#else -#define PERIPH_FREQUENCY 50000000 -#endif - #endif diff --git a/include/chips/pulpissimo/soc.h b/include/chips/pulpissimo/soc.h index 3b60974..71035a8 100644 --- a/include/chips/pulpissimo/soc.h +++ b/include/chips/pulpissimo/soc.h @@ -22,7 +22,7 @@ #define POS_FLL_PERIPH 1 #define POS_FLL_FC 0 -extern int pos_freq_domains[ARCHI_NB_FLL]; +extern int pos_freq_domains[PI_FREQ_NB_DOMAINS]; void pos_soc_init(); diff --git a/include/pulp.h b/include/pulp.h index 0b73277..2ddf606 100755 --- a/include/pulp.h +++ b/include/pulp.h @@ -31,7 +31,8 @@ typedef enum { PI_FREQ_DOMAIN_FC = 0, PI_FREQ_DOMAIN_CL = 1, - PI_FREQ_DOMAIN_PERIPH = 2 + PI_FREQ_DOMAIN_PERIPH = 2, + PI_FREQ_NB_DOMAINS = 3 } pi_freq_domain_e; #ifdef ARCHI_HAS_CLUSTER diff --git a/kernel/freq-domains.c b/kernel/freq-domains.c index aeaee05..ab7ccc5 100644 --- a/kernel/freq-domains.c +++ b/kernel/freq-domains.c @@ -18,7 +18,7 @@ #include -int pos_freq_domains[ARCHI_NB_FLL]; +int pos_freq_domains[PI_FREQ_NB_DOMAINS]; From 5b2fdb62a2b3d8d32d3ec5b41a0c76246a2ba555 Mon Sep 17 00:00:00 2001 From: Manuel Eggimann Date: Thu, 5 Mar 2020 16:16:31 +0100 Subject: [PATCH 09/12] Add additional FPGA config files --- configs/fpgas/pulpissimo/genesys2.sh | 14 ++++++++++++-- configs/fpgas/pulpissimo/nexys_video.sh | 22 ++++++++++++++++++++++ configs/fpgas/pulpissimo/zcu102.sh | 22 ++++++++++++++++++++++ configs/fpgas/pulpissimo/zcu104.sh | 22 ++++++++++++++++++++++ configs/fpgas/pulpissimo/zedboard.sh | 22 ++++++++++++++++++++++ 5 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 configs/fpgas/pulpissimo/nexys_video.sh create mode 100644 configs/fpgas/pulpissimo/zcu102.sh create mode 100644 configs/fpgas/pulpissimo/zcu104.sh create mode 100644 configs/fpgas/pulpissimo/zedboard.sh diff --git a/configs/fpgas/pulpissimo/genesys2.sh b/configs/fpgas/pulpissimo/genesys2.sh index f316e2b..6e87066 100644 --- a/configs/fpgas/pulpissimo/genesys2.sh +++ b/configs/fpgas/pulpissimo/genesys2.sh @@ -3,10 +3,20 @@ export PULPRT_TARGET=pulpissimo export PULPRUN_TARGET=pulpissimo -scriptDir="$(dirname "$(dirname "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")")")" +if [ -n "${ZSH_VERSION:-}" ]; then + DIR="$(readlink -f -- "${(%):-%x}")" + scriptDir="$(dirname $DIR)" +else -source $scriptDir/common.sh + scriptDir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" + +fi + +source $scriptDir/../../common.sh export PULPRUN_PLATFORM=fpga +#Genesys2 uses 10MHz SoC Frequency +export PULPRT_CONFIG_CFLAGS='-DARCHI_FPGA_FREQUENCY=10000000' + export io=uart diff --git a/configs/fpgas/pulpissimo/nexys_video.sh b/configs/fpgas/pulpissimo/nexys_video.sh new file mode 100644 index 0000000..47b473a --- /dev/null +++ b/configs/fpgas/pulpissimo/nexys_video.sh @@ -0,0 +1,22 @@ +#!/bin/bash -e + +export PULPRT_TARGET=pulpissimo +export PULPRUN_TARGET=pulpissimo + +if [ -n "${ZSH_VERSION:-}" ]; then + DIR="$(readlink -f -- "${(%):-%x}")" + scriptDir="$(dirname $DIR)" +else + + scriptDir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" + +fi + +source $scriptDir/../../common.sh + +export PULPRUN_PLATFORM=fpga + +#Nexys Video uses 5MHz SoC Frequency +export PULPRT_CONFIG_CFLAGS='-DARCHI_FPGA_FREQUENCY=5000000' + +export io=uart diff --git a/configs/fpgas/pulpissimo/zcu102.sh b/configs/fpgas/pulpissimo/zcu102.sh new file mode 100644 index 0000000..4eb9f63 --- /dev/null +++ b/configs/fpgas/pulpissimo/zcu102.sh @@ -0,0 +1,22 @@ +#!/bin/bash -e + +export PULPRT_TARGET=pulpissimo +export PULPRUN_TARGET=pulpissimo + +if [ -n "${ZSH_VERSION:-}" ]; then + DIR="$(readlink -f -- "${(%):-%x}")" + scriptDir="$(dirname $DIR)" +else + + scriptDir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" + +fi + +source $scriptDir/../../common.sh + +export PULPRUN_PLATFORM=fpga + +#ZCU102 uses 10MHz SoC Frequency +export PULPRT_CONFIG_CFLAGS='-DARCHI_FPGA_FREQUENCY=10000000' + +export io=uart diff --git a/configs/fpgas/pulpissimo/zcu104.sh b/configs/fpgas/pulpissimo/zcu104.sh new file mode 100644 index 0000000..68d5ac7 --- /dev/null +++ b/configs/fpgas/pulpissimo/zcu104.sh @@ -0,0 +1,22 @@ +#!/bin/bash -e + +export PULPRT_TARGET=pulpissimo +export PULPRUN_TARGET=pulpissimo + +if [ -n "${ZSH_VERSION:-}" ]; then + DIR="$(readlink -f -- "${(%):-%x}")" + scriptDir="$(dirname $DIR)" +else + + scriptDir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" + +fi + +source $scriptDir/../../common.sh + +export PULPRUN_PLATFORM=fpga + +#ZCU104 uses 10MHz SoC Frequency +export PULPRT_CONFIG_CFLAGS='-DARCHI_FPGA_FREQUENCY=10000000' + +export io=uart diff --git a/configs/fpgas/pulpissimo/zedboard.sh b/configs/fpgas/pulpissimo/zedboard.sh new file mode 100644 index 0000000..297ff38 --- /dev/null +++ b/configs/fpgas/pulpissimo/zedboard.sh @@ -0,0 +1,22 @@ +#!/bin/bash -e + +export PULPRT_TARGET=pulpissimo +export PULPRUN_TARGET=pulpissimo + +if [ -n "${ZSH_VERSION:-}" ]; then + DIR="$(readlink -f -- "${(%):-%x}")" + scriptDir="$(dirname $DIR)" +else + + scriptDir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" + +fi + +source $scriptDir/../../common.sh + +export PULPRUN_PLATFORM=fpga + +#Zedboard uses 10MHz SoC Frequency +export PULPRT_CONFIG_CFLAGS='-DARCHI_FPGA_FREQUENCY=10000000' + +export io=uart From df7d47dd56f7e5a970ff433d833dbd35e39f473e Mon Sep 17 00:00:00 2001 From: Angelo Garofalo Date: Sun, 15 Mar 2020 22:31:21 +0100 Subject: [PATCH 10/12] add fpga config for pulp & marsellus --- configs/fpgas/marsellus/virtex7.sh | 23 +++++++++++++++++++++++ configs/fpgas/pulp/virtex7.sh | 23 +++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 configs/fpgas/marsellus/virtex7.sh create mode 100644 configs/fpgas/pulp/virtex7.sh diff --git a/configs/fpgas/marsellus/virtex7.sh b/configs/fpgas/marsellus/virtex7.sh new file mode 100644 index 0000000..02a6612 --- /dev/null +++ b/configs/fpgas/marsellus/virtex7.sh @@ -0,0 +1,23 @@ + +#!/bin/bash -e + +export PULPRT_TARGET=marsellus +export PULPRUN_TARGET=marsellus + +if [ -n "${ZSH_VERSION:-}" ]; then + DIR="$(readlink -f -- "${(%):-%x}")" + scriptDir="$(dirname $DIR)" +else + + scriptDir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" + +fi + +source $scriptDir/../../common.sh + +export PULPRUN_PLATFORM=fpga + +#Virtex7 uses 50MHz SoC Frequency +export PULPRT_CONFIG_CFLAGS='-DARCHI_FPGA_FREQUENCY=50000000' + +export io=uart \ No newline at end of file diff --git a/configs/fpgas/pulp/virtex7.sh b/configs/fpgas/pulp/virtex7.sh new file mode 100644 index 0000000..5b31806 --- /dev/null +++ b/configs/fpgas/pulp/virtex7.sh @@ -0,0 +1,23 @@ + +#!/bin/bash -e + +export PULPRT_TARGET=pulp +export PULPRUN_TARGET=pulp + +if [ -n "${ZSH_VERSION:-}" ]; then + DIR="$(readlink -f -- "${(%):-%x}")" + scriptDir="$(dirname $DIR)" +else + + scriptDir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" + +fi + +source $scriptDir/../../common.sh + +export PULPRUN_PLATFORM=fpga + +#Virtex7 uses 50MHz SoC Frequency +export PULPRT_CONFIG_CFLAGS='-DARCHI_FPGA_FREQUENCY=50000000' + +export io=uart \ No newline at end of file From 1d7dcdd017f3446d1011f0107cf992e34fb2d4c8 Mon Sep 17 00:00:00 2001 From: Angelo Garofalo Date: Wed, 1 Apr 2020 20:33:28 +0200 Subject: [PATCH 11/12] add fpga config for marsellus --- configs/fpgas/marsellus/virtex7.sh | 5 ++--- include/archi/chips/marsellus/properties.h | 9 +++++++++ kernel/chips/marsellus/soc.c | 13 +++++++++++++ rules/pulpos/targets/marsellus.mk | 5 +++++ 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/configs/fpgas/marsellus/virtex7.sh b/configs/fpgas/marsellus/virtex7.sh index 02a6612..6a876c4 100644 --- a/configs/fpgas/marsellus/virtex7.sh +++ b/configs/fpgas/marsellus/virtex7.sh @@ -1,4 +1,3 @@ - #!/bin/bash -e export PULPRT_TARGET=marsellus @@ -18,6 +17,6 @@ source $scriptDir/../../common.sh export PULPRUN_PLATFORM=fpga #Virtex7 uses 50MHz SoC Frequency -export PULPRT_CONFIG_CFLAGS='-DARCHI_FPGA_FREQUENCY=50000000' +export PULPRT_CONFIG_CFLAGS='-DARCHI_FPGA_FREQUENCY=20000000' -export io=uart \ No newline at end of file +export io=uart diff --git a/include/archi/chips/marsellus/properties.h b/include/archi/chips/marsellus/properties.h index 248321d..28b9894 100644 --- a/include/archi/chips/marsellus/properties.h +++ b/include/archi/chips/marsellus/properties.h @@ -22,8 +22,17 @@ * FPGA */ +#ifndef ARCHI_FPGA_FREQUENCY #define ARCHI_FPGA_FREQUENCY 5000000 +#endif +#ifndef ARCHI_FPGA_FC_FREQUENCY +#define ARCHI_FPGA_FC_FREQUENCY 5000000 +#endif + +#ifndef ARCHI_FPGA_CL_FREQUENCY +#define ARCHI_FPGA_CL_FREQUENCY 5000000 +#endif /* * MEMORIES */ diff --git a/kernel/chips/marsellus/soc.c b/kernel/chips/marsellus/soc.c index 5c3c9a4..8626f91 100644 --- a/kernel/chips/marsellus/soc.c +++ b/kernel/chips/marsellus/soc.c @@ -18,12 +18,25 @@ void pos_soc_init() { +#if __PLATFORM__ != ARCHI_PLATFORM_FPGA + pos_fll_constructor(); pos_freq_domains[PI_FREQ_DOMAIN_FC] = pos_fll_init(POS_FLL_FC); pos_freq_domains[PI_FREQ_DOMAIN_PERIPH] = pos_fll_init(POS_FLL_PERIPH); + pos_freq_domains[PI_FREQ_DOMAIN_CL] = pos_fll_init(POS_FLL_CL); + +#else + + pos_freq_domains[PI_FREQ_DOMAIN_FC] = ARCHI_FPGA_FC_FREQUENCY; + + pos_freq_domains[PI_FREQ_DOMAIN_PERIPH] = ARCHI_FPGA_FREQUENCY; + + pos_freq_domains[PI_FREQ_DOMAIN_CL] = ARCHI_FPGA_CL_FREQUENCY; + +#endif } diff --git a/rules/pulpos/targets/marsellus.mk b/rules/pulpos/targets/marsellus.mk index 9b47b38..61e7fec 100644 --- a/rules/pulpos/targets/marsellus.mk +++ b/rules/pulpos/targets/marsellus.mk @@ -41,4 +41,9 @@ PULP_SRCS += kernel/chips/marsellus/soc.c include $(PULPRT_HOME)/rules/pulpos/configs/default.mk + +ifeq '$(platform)' 'fpga' +CONFIG_IO_UART=1 +endif + include $(PULPRT_HOME)/rules/pulpos/default_rules.mk \ No newline at end of file From b89dac68903449bd624525bc0e25b39c79d8a55f Mon Sep 17 00:00:00 2001 From: Angelo Garofalo Date: Wed, 1 Apr 2020 21:24:07 +0200 Subject: [PATCH 12/12] fix frequency for marsellus on fpga --- configs/fpgas/marsellus/virtex7.sh | 2 +- configs/fpgas/pulp/virtex7.sh | 2 +- include/archi/chips/marsellus/properties.h | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/configs/fpgas/marsellus/virtex7.sh b/configs/fpgas/marsellus/virtex7.sh index 6a876c4..40c5b7d 100644 --- a/configs/fpgas/marsellus/virtex7.sh +++ b/configs/fpgas/marsellus/virtex7.sh @@ -17,6 +17,6 @@ source $scriptDir/../../common.sh export PULPRUN_PLATFORM=fpga #Virtex7 uses 50MHz SoC Frequency -export PULPRT_CONFIG_CFLAGS='-DARCHI_FPGA_FREQUENCY=20000000' +export PULPRT_CONFIG_CFLAGS='-DARCHI_FPGA_FREQUENCY=10000000' export io=uart diff --git a/configs/fpgas/pulp/virtex7.sh b/configs/fpgas/pulp/virtex7.sh index 5b31806..9ae9201 100644 --- a/configs/fpgas/pulp/virtex7.sh +++ b/configs/fpgas/pulp/virtex7.sh @@ -18,6 +18,6 @@ source $scriptDir/../../common.sh export PULPRUN_PLATFORM=fpga #Virtex7 uses 50MHz SoC Frequency -export PULPRT_CONFIG_CFLAGS='-DARCHI_FPGA_FREQUENCY=50000000' +export PULPRT_CONFIG_CFLAGS='-DARCHI_FPGA_FREQUENCY=10000000' export io=uart \ No newline at end of file diff --git a/include/archi/chips/marsellus/properties.h b/include/archi/chips/marsellus/properties.h index 28b9894..735c687 100644 --- a/include/archi/chips/marsellus/properties.h +++ b/include/archi/chips/marsellus/properties.h @@ -23,15 +23,15 @@ */ #ifndef ARCHI_FPGA_FREQUENCY -#define ARCHI_FPGA_FREQUENCY 5000000 +#define ARCHI_FPGA_FREQUENCY 1000000 #endif #ifndef ARCHI_FPGA_FC_FREQUENCY -#define ARCHI_FPGA_FC_FREQUENCY 5000000 +#define ARCHI_FPGA_FC_FREQUENCY 2000000 #endif #ifndef ARCHI_FPGA_CL_FREQUENCY -#define ARCHI_FPGA_CL_FREQUENCY 5000000 +#define ARCHI_FPGA_CL_FREQUENCY 20000000 #endif /* * MEMORIES