]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/main.c
Recreate the RISC-V-Qemu demo using Vanilla Eclipse in place of Freedom Studio as...
[freertos] / FreeRTOS / Demo / RISC-V-Qemu-sifive_e-FreedomStudio / main.c
index ec5fd76245c68d0af7ec17ac82cf93d24bd6e421..07912293e2e09061bc8bc1ea630e3d169cc6cc5e 100644 (file)
@@ -1,6 +1,6 @@
 /*\r
- * FreeRTOS Kernel V10.1.1\r
- * Copyright (C) 2018 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
+ * FreeRTOS Kernel V10.2.1\r
+ * Copyright (C) 2019 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
  *\r
  * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
  * this software and associated documentation files (the "Software"), to deal in\r
  * THE http://www.FreeRTOS.org WEB SITE FOR FULL INFORMATION ON USING THIS DEMO\r
  * APPLICATION, AND ITS ASSOCIATE FreeRTOS ARCHITECTURE PORT!\r
  *\r
+ *\r
+ * NOTE 1:\r
+ *\r
+ * This project has only been tested in the QEMU emulation of the HiFive board\r
+ * from SiFive.\r
+ *\r
+ * Start QEMU using the following command line:\r
+ *\r
+ * [your_path_1]\qemu-system-riscv32 -kernel [your_path_2]\FreeRTOS\Demo\RISC-V-Qemu-sifive_e-FreedomStudio\Debug\RTOSDemo.elf -S -s -machine sifive_e\r
+ *\r
+ * Where [your_path_1] must be replaced with the correct path to your QEMU\r
+ * installation and the elf file generated by this project respectively.\r
+ *\r
+ *\r
+ * NOTE 2:\r
+ *\r
+ * Start GDB using the following command line (this can be entered in the\r
+ * Eclipse Debug Launch Configuration dialogue):\r
+ *\r
+ * riscv64-unknown-elf-gdb.exe -iex "set mem inaccessible-by-default off" -iex "set arch riscv:rv32" -iex "set riscv use_compressed_breakpoint off"\r
+ *\r
+ *\r
+ * Note 3:\r
+ *\r
+ * Status information is sent to the QEMU serial console.\r
  */\r
 \r
 /* Set mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to one to run the simple blinky demo,\r
 or 0 to run the more comprehensive test and demo application. */\r
-#define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY     1\r
+#define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY     0\r
 \r
 /*\r
  * main_blinky() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1.\r
@@ -60,17 +85,28 @@ or 0 to run the more comprehensive test and demo application. */
        extern void main_full( void );\r
 #endif /* #if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 */\r
 \r
-/* Prototypes for the standard FreeRTOS callback/hook functions implemented\r
-within this file.  See https://www.freertos.org/a00016.html */\r
+/*\r
+ * Prototypes for the standard FreeRTOS callback/hook functions implemented\r
+ * within this file.  See https://www.freertos.org/a00016.html\r
+ */\r
 void vApplicationMallocFailedHook( void );\r
 void vApplicationIdleHook( void );\r
 void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName );\r
 void vApplicationTickHook( void );\r
 \r
+/*\r
+ * Very simply polling write to the UART.  The full demo only writes single\r
+ * characters at a time so as not to disrupt the timing of the test and demo\r
+ * tasks.\r
+ */\r
+void vSendString( const char * pcString );\r
+\r
 /*-----------------------------------------------------------*/\r
 \r
 int main( void )\r
 {\r
+       vSendString( "Starting" );\r
+\r
        /* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top\r
        of this file. */\r
        #if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 )\r
@@ -98,7 +134,6 @@ void vApplicationMallocFailedHook( void )
        to query the size of free heap space that remains (although it does not\r
        provide information on how the remaining heap might be fragmented). */\r
        taskDISABLE_INTERRUPTS();\r
-//     __asm volatile( "ebreak" );\r
        for( ;; );\r
 }\r
 /*-----------------------------------------------------------*/\r
@@ -126,7 +161,6 @@ void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )
        configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2.  This hook\r
        function is called if a stack overflow is detected. */\r
        taskDISABLE_INTERRUPTS();\r
-//     __asm volatile( "ebreak" );\r
        for( ;; );\r
 }\r
 /*-----------------------------------------------------------*/\r
@@ -148,9 +182,20 @@ void vAssertCalled( void )
 volatile uint32_t ulSetTo1ToExitFunction = 0;\r
 \r
        taskDISABLE_INTERRUPTS();\r
-//     __asm volatile( "ebreak" );\r
        while( ulSetTo1ToExitFunction != 1 )\r
        {\r
                __asm volatile( "NOP" );\r
        }\r
 }\r
+/*-----------------------------------------------------------*/\r
+\r
+void vSendString( const char * pcString )\r
+{\r
+       while( *pcString != 0x00 )\r
+       {\r
+               while( UART0_REG( UART_REG_TXFIFO ) & 0x80000000 );\r
+               UART0_REG( UART_REG_TXFIFO ) = *pcString;\r
+               *pcString++;\r
+       }\r
+}\r
+\r