From: rtel Date: Wed, 16 Oct 2019 04:28:28 +0000 (+0000) Subject: Recreate the RISC-V-Qemu demo using Vanilla Eclipse in place of Freedom Studio as... X-Git-Tag: V10.3.0~81 X-Git-Url: https://git.sur5r.net/?p=freertos;a=commitdiff_plain;h=213b15149ddbb511e587ec60de3e2283c41d8a28;hp=5c2caaac2c4c97ef835be5e971beeba3eef327d0 Recreate the RISC-V-Qemu demo using Vanilla Eclipse in place of Freedom Studio as there is not a new Freedom Studio project that targets the HiFive1 board, and the updated Freedom Studio version didn't work with this project any more anyway. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2742 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- diff --git a/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/.cproject b/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/.cproject index 2f9dbd537..debca76bc 100644 --- a/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/.cproject +++ b/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/.cproject @@ -1,8 +1,8 @@ - - + + @@ -14,214 +14,80 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - + + - - - - diff --git a/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/.project b/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/.project index 2db361770..c1f63311d 100644 --- a/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/.project +++ b/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/.project @@ -25,120 +25,120 @@ - FreeRTOS_Source + freertos_source 2 virtual:/virtual - FreeRTOS_Source/event_groups.c + freertos_source/event_groups.c 1 FREERTOS_ROOT/FreeRTOS/Source/event_groups.c - FreeRTOS_Source/include + freertos_source/include 2 FREERTOS_ROOT/FreeRTOS/Source/include - FreeRTOS_Source/list.c + freertos_source/list.c 1 FREERTOS_ROOT/FreeRTOS/Source/list.c - FreeRTOS_Source/portable + freertos_source/portable 2 virtual:/virtual - FreeRTOS_Source/queue.c + freertos_source/queue.c 1 FREERTOS_ROOT/FreeRTOS/Source/queue.c - FreeRTOS_Source/stream_buffer.c + freertos_source/stream_buffer.c 1 FREERTOS_ROOT/FreeRTOS/Source/stream_buffer.c - FreeRTOS_Source/tasks.c + freertos_source/tasks.c 1 FREERTOS_ROOT/FreeRTOS/Source/tasks.c - FreeRTOS_Source/timers.c + freertos_source/timers.c 1 FREERTOS_ROOT/FreeRTOS/Source/timers.c - full_demo/common_demo_tasks + full_demo/standard_demo_tasks 2 virtual:/virtual - FreeRTOS_Source/portable/GCC + freertos_source/portable/GCC 2 virtual:/virtual - FreeRTOS_Source/portable/MemMang + freertos_source/portable/MemMang 2 virtual:/virtual - full_demo/common_demo_tasks/EventGroupsDemo.c + full_demo/standard_demo_tasks/EventGroupsDemo.c 1 FREERTOS_ROOT/FreeRTOS/Demo/Common/Minimal/EventGroupsDemo.c - full_demo/common_demo_tasks/GenQTest.c + full_demo/standard_demo_tasks/GenQTest.c 1 FREERTOS_ROOT/FreeRTOS/Demo/Common/Minimal/GenQTest.c - full_demo/common_demo_tasks/TaskNotify.c + full_demo/standard_demo_tasks/TaskNotify.c 1 FREERTOS_ROOT/FreeRTOS/Demo/Common/Minimal/TaskNotify.c - full_demo/common_demo_tasks/TimerDemo.c + full_demo/standard_demo_tasks/TimerDemo.c 1 FREERTOS_ROOT/FreeRTOS/Demo/Common/Minimal/TimerDemo.c - full_demo/common_demo_tasks/blocktim.c + full_demo/standard_demo_tasks/blocktim.c 1 FREERTOS_ROOT/FreeRTOS/Demo/Common/Minimal/blocktim.c - full_demo/common_demo_tasks/dynamic.c + full_demo/standard_demo_tasks/dynamic.c 1 FREERTOS_ROOT/FreeRTOS/Demo/Common/Minimal/dynamic.c - full_demo/common_demo_tasks/include + full_demo/standard_demo_tasks/include 2 FREERTOS_ROOT/FreeRTOS/Demo/Common/include - full_demo/common_demo_tasks/recmutex.c + full_demo/standard_demo_tasks/recmutex.c 1 FREERTOS_ROOT/FreeRTOS/Demo/Common/Minimal/recmutex.c - FreeRTOS_Source/portable/GCC/RISC-V + freertos_source/portable/GCC/RISC-V 2 FREERTOS_ROOT/FreeRTOS/Source/portable/GCC/RISC-V - FreeRTOS_Source/portable/MemMang/heap_4.c + freertos_source/portable/MemMang/heap_4.c 1 FREERTOS_ROOT/FreeRTOS/Source/portable/MemMang/heap_4.c - 1546280186727 - FreeRTOS_Source/portable/GCC/RISC-V/chip_specific_extensions + 1571146760235 + freertos_source/portable/GCC/RISC-V/chip_specific_extensions 9 org.eclipse.ui.ide.multiFilter diff --git a/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/.settings/language.settings.xml b/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/.settings/language.settings.xml index f4d8f4687..97f9f0d9f 100644 --- a/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/.settings/language.settings.xml +++ b/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/.settings/language.settings.xml @@ -1,48 +1,14 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + diff --git a/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/FreeRTOSConfig.h b/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/FreeRTOSConfig.h index f239c1c3c..c48a10b3a 100644 --- a/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/FreeRTOSConfig.h +++ b/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/FreeRTOSConfig.h @@ -103,7 +103,7 @@ #define configTICK_RATE_HZ ( ( TickType_t ) 1000 ) #define configMAX_PRIORITIES ( 7 ) #define configMINIMAL_STACK_SIZE ( ( unsigned short ) 70 ) -#define configTOTAL_HEAP_SIZE ( ( size_t ) 14100 ) +#define configTOTAL_HEAP_SIZE ( ( size_t ) 14500 ) #define configMAX_TASK_NAME_LEN ( 16 ) #define configUSE_TRACE_FACILITY 0 #define configUSE_16_BIT_TICKS 0 @@ -126,7 +126,7 @@ #define configUSE_TIMERS 1 #define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 ) #define configTIMER_QUEUE_LENGTH 4 -#define configTIMER_TASK_STACK_DEPTH ( 100 ) +#define configTIMER_TASK_STACK_DEPTH ( 120 ) /* Task priorities. Allow these to be overridden. */ #ifndef uartPRIMARY_PRIORITY @@ -144,6 +144,9 @@ to exclude the API function. */ #define INCLUDE_vTaskDelay 1 #define INCLUDE_eTaskGetState 1 #define INCLUDE_xTimerPendFunctionCall 1 +#define INCLUDE_xTaskAbortDelay 1 +#define INCLUDE_xTaskGetHandle 1 +#define INCLUDE_xSemaphoreGetMutexHolder 1 /* Normal assert() semantics without relying on the provision of an assert.h header file. */ diff --git a/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/Hardware_Qemu.launch b/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/Hardware_Qemu.launch index ad57bf591..c95af4eb0 100644 --- a/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/Hardware_Qemu.launch +++ b/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/Hardware_Qemu.launch @@ -8,6 +8,7 @@ + @@ -25,6 +26,8 @@ + + diff --git a/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/blinky_demo/main_blinky.c b/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/blinky_demo/main_blinky.c index 78b3747db..96b9f9110 100644 --- a/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/blinky_demo/main_blinky.c +++ b/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/blinky_demo/main_blinky.c @@ -175,6 +175,7 @@ unsigned long ulReceivedValue; const unsigned long ulExpectedValue = 100UL; const char * const pcPassMessage = "Blink\r\n"; const char * const pcFailMessage = "Unexpected value received\r\n"; +extern void vSendString( const char * pcString ); /* Remove compiler warning about unused parameter. */ ( void ) pvParameters; @@ -190,12 +191,12 @@ const char * const pcFailMessage = "Unexpected value received\r\n"; is it the expected value? If it is, toggle the LED. */ if( ulReceivedValue == ulExpectedValue ) { - write( STDOUT_FILENO, pcPassMessage, strlen( pcPassMessage ) ); + vSendString( pcPassMessage ); ulReceivedValue = 0U; } else { - write( STDOUT_FILENO, pcFailMessage, strlen( pcFailMessage ) ); + vSendString( pcFailMessage ); } } } diff --git a/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/freedom-e-sdk/drivers/fe300prci/fe300prci_driver.c b/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/freedom-e-sdk/drivers/fe300prci/fe300prci_driver.c deleted file mode 100644 index 214b1d5b6..000000000 --- a/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/freedom-e-sdk/drivers/fe300prci/fe300prci_driver.c +++ /dev/null @@ -1,252 +0,0 @@ -// See LICENSE file for license details - -#include "platform.h" - -#ifdef PRCI_CTRL_ADDR -#include "fe300prci/fe300prci_driver.h" -#include - -#define rdmcycle(x) { \ - uint32_t lo, hi, hi2; \ - __asm__ __volatile__ ("1:\n\t" \ - "csrr %0, mcycleh\n\t" \ - "csrr %1, mcycle\n\t" \ - "csrr %2, mcycleh\n\t" \ - "bne %0, %2, 1b\n\t" \ - : "=r" (hi), "=r" (lo), "=r" (hi2)) ; \ - *(x) = lo | ((uint64_t) hi << 32); \ - } - -uint32_t PRCI_measure_mcycle_freq(uint32_t mtime_ticks, uint32_t mtime_freq) -{ - - uint32_t start_mtime = CLINT_REG(CLINT_MTIME); - uint32_t end_mtime = start_mtime + mtime_ticks + 1; - - // Make sure we won't get rollover. - while (end_mtime < start_mtime){ - start_mtime = CLINT_REG(CLINT_MTIME); - end_mtime = start_mtime + mtime_ticks + 1; - } - - // Don't start measuring until mtime edge. - uint32_t tmp = start_mtime; - do { - start_mtime = CLINT_REG(CLINT_MTIME); - } while (start_mtime == tmp); - - uint64_t start_mcycle; - rdmcycle(&start_mcycle); - - while (CLINT_REG(CLINT_MTIME) < end_mtime) ; - - uint64_t end_mcycle; - rdmcycle(&end_mcycle); - uint32_t difference = (uint32_t) (end_mcycle - start_mcycle); - - uint64_t freq = ((uint64_t) difference * mtime_freq) / mtime_ticks; - return (uint32_t) freq & 0xFFFFFFFF; - -} - - -void PRCI_use_hfrosc(int div, int trim) -{ - // Make sure the HFROSC is running at its default setting - // It is OK to change this even if we are running off of it. - - PRCI_REG(PRCI_HFROSCCFG) = (ROSC_DIV(div) | ROSC_TRIM(trim) | ROSC_EN(1)); - - while ((PRCI_REG(PRCI_HFROSCCFG) & ROSC_RDY(1)) == 0); - - PRCI_REG(PRCI_PLLCFG) &= ~PLL_SEL(1); -} - -void PRCI_use_pll(int refsel, int bypass, - int r, int f, int q, int finaldiv, - int hfroscdiv, int hfrosctrim) -{ - // Ensure that we aren't running off the PLL before we mess with it. - if (PRCI_REG(PRCI_PLLCFG) & PLL_SEL(1)) { - // Make sure the HFROSC is running at its default setting - PRCI_use_hfrosc(4, 16); - } - - // Set PLL Source to be HFXOSC if desired. - uint32_t config_value = 0; - - config_value |= PLL_REFSEL(refsel); - - if (bypass) { - // Bypass - config_value |= PLL_BYPASS(1); - - PRCI_REG(PRCI_PLLCFG) = config_value; - - // If we don't have an HFXTAL, this doesn't really matter. - // Set our Final output divide to divide-by-1: - PRCI_REG(PRCI_PLLDIV) = (PLL_FINAL_DIV_BY_1(1) | PLL_FINAL_DIV(0)); - } else { - - // To overclock, use the hfrosc - if (hfrosctrim >= 0 && hfroscdiv >= 0) { - PRCI_use_hfrosc(hfroscdiv, hfrosctrim); - } - - // Set DIV Settings for PLL - - // (Legal values of f_REF are 6-48MHz) - - // Set DIVR to divide-by-2 to get 8MHz frequency - // (legal values of f_R are 6-12 MHz) - - config_value |= PLL_BYPASS(1); - config_value |= PLL_R(r); - - // Set DIVF to get 512Mhz frequncy - // There is an implied multiply-by-2, 16Mhz. - // So need to write 32-1 - // (legal values of f_F are 384-768 MHz) - config_value |= PLL_F(f); - - // Set DIVQ to divide-by-2 to get 256 MHz frequency - // (legal values of f_Q are 50-400Mhz) - config_value |= PLL_Q(q); - - // Set our Final output divide to divide-by-1: - if (finaldiv == 1){ - PRCI_REG(PRCI_PLLDIV) = (PLL_FINAL_DIV_BY_1(1) | PLL_FINAL_DIV(0)); - } else { - PRCI_REG(PRCI_PLLDIV) = (PLL_FINAL_DIV(finaldiv-1)); - } - - PRCI_REG(PRCI_PLLCFG) = config_value; - - // Un-Bypass the PLL. - PRCI_REG(PRCI_PLLCFG) &= ~PLL_BYPASS(1); - - // Wait for PLL Lock - // Note that the Lock signal can be glitchy. - // Need to wait 100 us - // RTC is running at 32kHz. - // So wait 4 ticks of RTC. - uint32_t now = CLINT_REG(CLINT_MTIME); - while (CLINT_REG(CLINT_MTIME) - now < 4) ; - - // Now it is safe to check for PLL Lock - while ((PRCI_REG(PRCI_PLLCFG) & PLL_LOCK(1)) == 0); - - } - - // Switch over to PLL Clock source - PRCI_REG(PRCI_PLLCFG) |= PLL_SEL(1); - - // If we're running off HFXOSC, turn off the HFROSC to - // save power. - if (refsel) { - PRCI_REG(PRCI_HFROSCCFG) &= ~ROSC_EN(1); - } - -} - -void PRCI_use_default_clocks() -{ - // Turn off the LFROSC - AON_REG(AON_LFROSC) &= ~ROSC_EN(1); - - // Use HFROSC - PRCI_use_hfrosc(4, 16); -} - -void PRCI_use_hfxosc(uint32_t finaldiv) -{ - - PRCI_use_pll(1, // Use HFXTAL - 1, // Bypass = 1 - 0, // PLL settings don't matter - 0, // PLL settings don't matter - 0, // PLL settings don't matter - finaldiv, - -1, - -1); -} - -// This is a generic function, which -// doesn't span the entire range of HFROSC settings. -// It only adjusts the trim, which can span a hundred MHz or so. -// This function does not check the legality of the PLL settings -// at all, and it is quite possible to configure invalid PLL settings -// this way. -// It returns the actual measured CPU frequency. - -uint32_t PRCI_set_hfrosctrim_for_f_cpu(uint32_t f_cpu, PRCI_freq_target target ) -{ - - uint32_t hfrosctrim = 0; - uint32_t hfroscdiv = 4; - uint32_t prev_trim = 0; - - // In this function we use PLL settings which - // will give us a 32x multiplier from the output - // of the HFROSC source to the output of the - // PLL. We first measure our HFROSC to get the - // right trim, then finally use it as the PLL source. - // We should really check here that the f_cpu - // requested is something in the limit of the PLL. For - // now that is up to the user. - - // This will undershoot for frequencies not divisible by 16. - uint32_t desired_hfrosc_freq = (f_cpu/ 16); - - PRCI_use_hfrosc(hfroscdiv, hfrosctrim); - - // Ignore the first run (for icache reasons) - uint32_t cpu_freq = PRCI_measure_mcycle_freq(3000, RTC_FREQ); - - cpu_freq = PRCI_measure_mcycle_freq(3000, RTC_FREQ); - uint32_t prev_freq = cpu_freq; - - while ((cpu_freq < desired_hfrosc_freq) && (hfrosctrim < 0x1F)){ - prev_trim = hfrosctrim; - prev_freq = cpu_freq; - hfrosctrim ++; - PRCI_use_hfrosc(hfroscdiv, hfrosctrim); - cpu_freq = PRCI_measure_mcycle_freq(3000, RTC_FREQ); - } - - // We couldn't go low enough - if (prev_freq > desired_hfrosc_freq){ - PRCI_use_pll(0, 0, 1, 31, 1, 1, hfroscdiv, prev_trim); - cpu_freq = PRCI_measure_mcycle_freq(1000, RTC_FREQ); - return cpu_freq; - } - - // We couldn't go high enough - if (cpu_freq < desired_hfrosc_freq){ - PRCI_use_pll(0, 0, 1, 31, 1, 1, hfroscdiv, prev_trim); - cpu_freq = PRCI_measure_mcycle_freq(1000, RTC_FREQ); - return cpu_freq; - } - - // Check for over/undershoot - switch(target) { - case(PRCI_FREQ_CLOSEST): - if ((desired_hfrosc_freq - prev_freq) < (cpu_freq - desired_hfrosc_freq)) { - PRCI_use_pll(0, 0, 1, 31, 1, 1, hfroscdiv, prev_trim); - } else { - PRCI_use_pll(0, 0, 1, 31, 1, 1, hfroscdiv, hfrosctrim); - } - break; - case(PRCI_FREQ_UNDERSHOOT): - PRCI_use_pll(0, 0, 1, 31, 1, 1, hfroscdiv, prev_trim); - break; - default: - PRCI_use_pll(0, 0, 1, 31, 1, 1, hfroscdiv, hfrosctrim); - } - - cpu_freq = PRCI_measure_mcycle_freq(1000, RTC_FREQ); - return cpu_freq; - -} - -#endif diff --git a/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/freedom-e-sdk/drivers/fe300prci/fe300prci_driver.h b/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/freedom-e-sdk/drivers/fe300prci/fe300prci_driver.h deleted file mode 100644 index 5ad9c0cad..000000000 --- a/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/freedom-e-sdk/drivers/fe300prci/fe300prci_driver.h +++ /dev/null @@ -1,79 +0,0 @@ -// See LICENSE file for license details - -#ifndef _FE300PRCI_DRIVER_H_ -#define _FE300PRCI_DRIVER_H_ - -__BEGIN_DECLS - -#include - -typedef enum prci_freq_target { - - PRCI_FREQ_OVERSHOOT, - PRCI_FREQ_CLOSEST, - PRCI_FREQ_UNDERSHOOT - -} PRCI_freq_target; - -/* Measure and return the approximate frequency of the - * CPU, as given by measuring the mcycle counter against - * the mtime ticks. - */ -uint32_t PRCI_measure_mcycle_freq(uint32_t mtime_ticks, uint32_t mtime_freq); - -/* Safely switch over to the HFROSC using the given div - * and trim settings. - */ -void PRCI_use_hfrosc(int div, int trim); - -/* Safely switch over to the 16MHz HFXOSC, - * applying the finaldiv clock divider (1 is the lowest - * legal value). - */ -void PRCI_use_hfxosc(uint32_t finaldiv); - -/* Safely switch over to the PLL using the given - * settings. - * - * Note that not all combinations of the inputs are actually - * legal, and this function does not check for their - * legality ("safely" means that this function won't turn off - * or glitch the clock the CPU is actually running off, but - * doesn't protect against you making it too fast or slow.) - */ - -void PRCI_use_pll(int refsel, int bypass, - int r, int f, int q, int finaldiv, - int hfroscdiv, int hfrosctrim); - -/* Use the default clocks configured at reset. - * This is ~16Mhz HFROSC and turns off the LFROSC - * (on the current FE310 Dev Platforms, an external LFROSC is - * used as it is more power efficient). - */ -void PRCI_use_default_clocks(); - -/* This routine will adjust the HFROSC trim - * while using HFROSC as the clock source, - * measure the resulting frequency, then - * use it as the PLL clock source, - * in an attempt to get over, under, or close to the - * requested frequency. It returns the actual measured - * frequency. - * - * Note that the requested frequency must be within the - * range supported by the PLL so not all values are - * achievable with this function, and not all - * are guaranteed to actually work. The PLL - * is rated higher than the hardware. - * - * There is no check on the desired f_cpu frequency, it - * is up to the user to specify something reasonable. - */ - -uint32_t PRCI_set_hfrosctrim_for_f_cpu(uint32_t f_cpu, PRCI_freq_target target); - -__END_DECLS - -#endif - diff --git a/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/freedom-e-sdk/drivers/plic/plic_driver.c b/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/freedom-e-sdk/drivers/plic/plic_driver.c deleted file mode 100644 index 4f0e49541..000000000 --- a/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/freedom-e-sdk/drivers/plic/plic_driver.c +++ /dev/null @@ -1,127 +0,0 @@ -// See LICENSE for license details. - -#include "sifive/devices/plic.h" -#include "plic/plic_driver.h" -#include "platform.h" -#include "encoding.h" -#include - - -// Note that there are no assertions or bounds checking on these -// parameter values. - -void volatile_memzero(uint8_t * base, unsigned int size) -{ - volatile uint8_t * ptr; - for (ptr = base; ptr < (base + size); ptr++){ - *ptr = 0; - } -} - -void PLIC_init ( - plic_instance_t * this_plic, - uintptr_t base_addr, - uint32_t num_sources, - uint32_t num_priorities - ) -{ - - this_plic->base_addr = base_addr; - this_plic->num_sources = num_sources; - this_plic->num_priorities = num_priorities; - - // Disable all interrupts (don't assume that these registers are reset). - unsigned long hart_id = read_csr(mhartid); - volatile_memzero((uint8_t*) (this_plic->base_addr + - PLIC_ENABLE_OFFSET + - (hart_id << PLIC_ENABLE_SHIFT_PER_TARGET)), - (num_sources + 8) / 8); - - // Set all priorities to 0 (equal priority -- don't assume that these are reset). - volatile_memzero ((uint8_t *)(this_plic->base_addr + - PLIC_PRIORITY_OFFSET), - (num_sources + 1) << PLIC_PRIORITY_SHIFT_PER_SOURCE); - - // Set the threshold to 0. - volatile plic_threshold* threshold = (plic_threshold*) - (this_plic->base_addr + - PLIC_THRESHOLD_OFFSET + - (hart_id << PLIC_THRESHOLD_SHIFT_PER_TARGET)); - - *threshold = 0; - -} - -void PLIC_set_threshold (plic_instance_t * this_plic, - plic_threshold threshold){ - - unsigned long hart_id = read_csr(mhartid); - volatile plic_threshold* threshold_ptr = (plic_threshold*) (this_plic->base_addr + - PLIC_THRESHOLD_OFFSET + - (hart_id << PLIC_THRESHOLD_SHIFT_PER_TARGET)); - - *threshold_ptr = threshold; - -} - - -void PLIC_enable_interrupt (plic_instance_t * this_plic, plic_source source){ - - unsigned long hart_id = read_csr(mhartid); - volatile uint8_t * current_ptr = (volatile uint8_t *)(this_plic->base_addr + - PLIC_ENABLE_OFFSET + - (hart_id << PLIC_ENABLE_SHIFT_PER_TARGET) + - (source >> 3)); - uint8_t current = *current_ptr; - current = current | ( 1 << (source & 0x7)); - *current_ptr = current; - -} - -void PLIC_disable_interrupt (plic_instance_t * this_plic, plic_source source){ - - unsigned long hart_id = read_csr(mhartid); - volatile uint8_t * current_ptr = (volatile uint8_t *) (this_plic->base_addr + - PLIC_ENABLE_OFFSET + - (hart_id << PLIC_ENABLE_SHIFT_PER_TARGET) + - (source >> 3)); - uint8_t current = *current_ptr; - current = current & ~(( 1 << (source & 0x7))); - *current_ptr = current; - -} - -void PLIC_set_priority (plic_instance_t * this_plic, plic_source source, plic_priority priority){ - - if (this_plic->num_priorities > 0) { - volatile plic_priority * priority_ptr = (volatile plic_priority *) - (this_plic->base_addr + - PLIC_PRIORITY_OFFSET + - (source << PLIC_PRIORITY_SHIFT_PER_SOURCE)); - *priority_ptr = priority; - } -} - -plic_source PLIC_claim_interrupt(plic_instance_t * this_plic){ - - unsigned long hart_id = read_csr(mhartid); - - volatile plic_source * claim_addr = (volatile plic_source * ) - (this_plic->base_addr + - PLIC_CLAIM_OFFSET + - (hart_id << PLIC_CLAIM_SHIFT_PER_TARGET)); - - return *claim_addr; - -} - -void PLIC_complete_interrupt(plic_instance_t * this_plic, plic_source source){ - - unsigned long hart_id = read_csr(mhartid); - volatile plic_source * claim_addr = (volatile plic_source *) (this_plic->base_addr + - PLIC_CLAIM_OFFSET + - (hart_id << PLIC_CLAIM_SHIFT_PER_TARGET)); - *claim_addr = source; - -} - diff --git a/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/freedom-e-sdk/drivers/plic/plic_driver.h b/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/freedom-e-sdk/drivers/plic/plic_driver.h deleted file mode 100644 index 8ce8e5131..000000000 --- a/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/freedom-e-sdk/drivers/plic/plic_driver.h +++ /dev/null @@ -1,51 +0,0 @@ -// See LICENSE file for licence details - -#ifndef PLIC_DRIVER_H -#define PLIC_DRIVER_H - - -__BEGIN_DECLS - -#include "platform.h" - -typedef struct __plic_instance_t -{ - uintptr_t base_addr; - - uint32_t num_sources; - uint32_t num_priorities; - -} plic_instance_t; - -typedef uint32_t plic_source; -typedef uint32_t plic_priority; -typedef uint32_t plic_threshold; - -void PLIC_init ( - plic_instance_t * this_plic, - uintptr_t base_addr, - uint32_t num_sources, - uint32_t num_priorities - ); - -void PLIC_set_threshold (plic_instance_t * this_plic, - plic_threshold threshold); - -void PLIC_enable_interrupt (plic_instance_t * this_plic, - plic_source source); - -void PLIC_disable_interrupt (plic_instance_t * this_plic, - plic_source source); - -void PLIC_set_priority (plic_instance_t * this_plic, - plic_source source, - plic_priority priority); - -plic_source PLIC_claim_interrupt(plic_instance_t * this_plic); - -void PLIC_complete_interrupt(plic_instance_t * this_plic, - plic_source source); - -__END_DECLS - -#endif diff --git a/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/freedom-e-sdk/env/freedom-e300-hifive1/flash.lds b/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/freedom-e-sdk/env/freedom-e300-hifive1/flash.lds index 0b7e75491..44639ee71 100644 --- a/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/freedom-e-sdk/env/freedom-e300-hifive1/flash.lds +++ b/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/freedom-e-sdk/env/freedom-e300-hifive1/flash.lds @@ -17,7 +17,7 @@ PHDRS SECTIONS { - __stack_size = DEFINED(__stack_size) ? __stack_size : 2K; + __stack_size = DEFINED(__stack_size) ? __stack_size : 400; .init : { diff --git a/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/freedom-e-sdk/env/freedom-e300-hifive1/init.c b/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/freedom-e-sdk/env/freedom-e300-hifive1/init.c index a0800e8f3..64fa6ef10 100644 --- a/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/freedom-e-sdk/env/freedom-e300-hifive1/init.c +++ b/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/freedom-e-sdk/env/freedom-e300-hifive1/init.c @@ -222,8 +222,6 @@ void _init() use_pll(0, 0, 1, 31, 1); uart_init(115200); - printf("core freq at %d Hz\n", (int)get_cpu_freq()); - write_csr(mtvec, &trap_entry); if (read_csr(misa) & (1 << ('F' - 'A'))) { // if F extension is present write_csr(mstatus, MSTATUS_FS); // allow FPU instructions without trapping diff --git a/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/full_demo/main_full.c b/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/full_demo/main_full.c index bd79bcb02..6c053a7ff 100644 --- a/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/full_demo/main_full.c +++ b/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/full_demo/main_full.c @@ -196,12 +196,11 @@ TickType_t xLastExecutionTime; static unsigned long ulLastRegTest1Value = 0, ulLastRegTest2Value = 0; const char * const pcPassMessage = "Pass"; const char * pcStatusMessage = "."; +extern void vSendString( const char * pcString ); /* Just to stop compiler warnings. */ ( void ) pvParameters; - write( STDOUT_FILENO, pcPassMessage, strlen( pcPassMessage ) ); - /* Initialise xLastExecutionTime so the first call to vTaskDelayUntil() works correctly. */ xLastExecutionTime = xTaskGetTickCount(); @@ -269,7 +268,7 @@ const char * pcStatusMessage = "."; ulLastRegTest2Value = ulRegTest2LoopCounter; /* Write the status message to the UART. */ - write( STDOUT_FILENO, pcStatusMessage, strlen( pcStatusMessage ) ); + vSendString( pcStatusMessage ); } } /*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/main.c b/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/main.c index 5c820394b..07912293e 100644 --- a/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/main.c +++ b/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/main.c @@ -73,7 +73,7 @@ /* Set mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to one to run the simple blinky demo, or 0 to run the more comprehensive test and demo application. */ -#define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY 1 +#define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY 0 /* * main_blinky() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1. @@ -85,17 +85,28 @@ or 0 to run the more comprehensive test and demo application. */ extern void main_full( void ); #endif /* #if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 */ -/* Prototypes for the standard FreeRTOS callback/hook functions implemented -within this file. See https://www.freertos.org/a00016.html */ +/* + * Prototypes for the standard FreeRTOS callback/hook functions implemented + * within this file. See https://www.freertos.org/a00016.html + */ void vApplicationMallocFailedHook( void ); void vApplicationIdleHook( void ); void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName ); void vApplicationTickHook( void ); +/* + * Very simply polling write to the UART. The full demo only writes single + * characters at a time so as not to disrupt the timing of the test and demo + * tasks. + */ +void vSendString( const char * pcString ); + /*-----------------------------------------------------------*/ int main( void ) { + vSendString( "Starting" ); + /* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top of this file. */ #if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 ) @@ -176,3 +187,15 @@ volatile uint32_t ulSetTo1ToExitFunction = 0; __asm volatile( "NOP" ); } } +/*-----------------------------------------------------------*/ + +void vSendString( const char * pcString ) +{ + while( *pcString != 0x00 ) + { + while( UART0_REG( UART_REG_TXFIFO ) & 0x80000000 ); + UART0_REG( UART_REG_TXFIFO ) = *pcString; + *pcString++; + } +} + diff --git a/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/sifive-freedom-e300-hifive1.cfg b/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/sifive-freedom-e300-hifive1.cfg deleted file mode 100644 index d0af4dd74..000000000 --- a/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/sifive-freedom-e300-hifive1.cfg +++ /dev/null @@ -1,34 +0,0 @@ -adapter_khz 10000 - -interface ftdi -ftdi_device_desc "Dual RS232-HS" -ftdi_vid_pid 0x0403 0x6010 - -ftdi_layout_init 0x0008 0x001b -ftdi_layout_signal nSRST -oe 0x0020 -data 0x0020 - -#Reset Stretcher logic on FE310 is ~1 second long -#This doesn't apply if you use -# ftdi_set_signal, but still good to document -#adapter_nsrst_delay 1500 - -set _CHIPNAME riscv -jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x10e31913 - -set _TARGETNAME $_CHIPNAME.cpu -target create $_TARGETNAME riscv -chain-position $_TARGETNAME -$_TARGETNAME configure -work-area-phys 0x80000000 -work-area-size 10000 -work-area-backup 1 - -flash bank onboard_spi_flash fespi 0x20000000 0 0 0 $_TARGETNAME -init -#reset -- This type of reset is not implemented yet -if {[ info exists pulse_srst]} { - ftdi_set_signal nSRST 0 - ftdi_set_signal nSRST z - #Wait for the reset stretcher - #It will work without this, but - #will incur lots of delays for later commands. - sleep 1500 -} -halt -flash protect 0 64 last off