Radix cross Linux

The main Radix cross Linux repository contains the build scripts of packages, which have the most complete and common functionality for desktop machines

452 Commits   2 Branches   1 Tag
Index: Makefile
===================================================================
--- Makefile	(nonexistent)
+++ Makefile	(revision 411)
@@ -0,0 +1,43 @@
+
+# GD32VF103 Linker Script:
+LDFLAGS += -T../device/gd32vf103xb.ld
+
+# Source files:
+AS_SRC  = ../device/gd32vf103xb_boot.S
+C_SRC   = main.c
+C_SRC  += ../device/n200_func.c
+
+# Header file directories:
+INCLUDE = -I../device/include
+
+# Object files to build:
+OBJS  = $(AS_SRC:.S=.o)
+OBJS += $(C_SRC:.c=.o)
+
+# Default rule to build the whole project:
+.PHONY: all
+all: main.bin
+
+# Rule to build assembly files:
+%.o: %.S
+	$(CC) -x assembler-with-cpp -c $(CFLAGS) $(INCLUDE) $< -o $@
+
+# Rule to compile C files:
+%.o: %.c
+	$(CC) -c $(CFLAGS) $(INCLUDE) $< -o $@
+
+# Rule to create an ELF file from the compiled object files:
+main.elf: $(OBJS)
+	$(CC) $^ $(LDFLAGS) -o $@
+
+# Rule to create a raw binary file from an ELF file:
+main.bin: main.elf
+	$(OBJCOPY) -S -O binary $< $@
+	$(SIZE) $<
+
+# Rule to clear out generated build files:
+.PHONY: clean
+clean:
+	rm -f $(OBJS)
+	rm -f main.elf
+	rm -f main.bin
Index: main.c
===================================================================
--- main.c	(nonexistent)
+++ main.c	(revision 411)
@@ -0,0 +1,80 @@
+
+#include <stdint.h>
+#include <string.h>
+
+// Device header files.
+#include <gd32vf103.h>
+#include <riscv_encoding.h>
+
+/*
+  Uncomment this line if you have only -march=rv32imac instead of -march=rv32imac_zicsr:
+__asm("\t.option arch, +zicsr");
+ */
+
+/* Pre-defined memory locations for program initialization */
+extern uint32_t _sidata, _sdata, _edata, _sbss, _ebss;
+/* Current system core clock speed */
+volatile uint32_t SystemCoreClock = 8000000;
+
+/* Simple 'busy loop' delay method */
+__attribute__( ( optimize( "O0" ) ) )
+void delay_cycles( uint32_t cyc ) {
+  uint32_t d_i;
+  for ( d_i = 0; d_i < cyc; ++d_i ) { __asm__( "nop" );
+  }
+}
+
+/* 'main' method which gets called from the boot code */
+int main( void )
+{
+  /* Copy initialized data from .sidata (Flash) to .data (RAM) */
+  memcpy( &_sdata, &_sidata, ( ( void* )&_edata - ( void* )&_sdata ) );
+  /* Clear the .bss RAM section */
+  memset( &_sbss, 0x00, ( ( void* )&_ebss - ( void* )&_sbss ) );
+
+  /* Enable the GPIOA and GPIOC peripherals */
+  RCC->APB2ENR |=  ( RCC_APB2ENR_IOPAEN |
+                     RCC_APB2ENR_IOPCEN );
+
+  /* Configure pins A1, A2, and C13 as low-speed push-pull outputs */
+  GPIOA->CRL   &= ~( GPIO_CRL_MODE1 | GPIO_CRL_CNF1 |
+                     GPIO_CRL_MODE2 | GPIO_CRL_CNF2 );
+  GPIOA->CRL   |=  ( ( 0x2 << GPIO_CRL_MODE1_Pos ) |
+                     ( 0x2 << GPIO_CRL_MODE2_Pos ) );
+  GPIOC->CRH   &= ~( GPIO_CRH_MODE13 | GPIO_CRH_CNF13 );
+  GPIOC->CRH   |=  ( 0x2 << GPIO_CRH_MODE13_Pos );
+
+  /********************************************************
+    Turn all three LEDs off.
+    The pins are connected to the LED cathodes, so pulling
+    the pin high turns the LED off, and low turns it on.
+   */
+  GPIOA->ODR   |=  ( 0x1 << 1 |
+                     0x1 << 2 );
+  GPIOC->ODR   |=  ( 0x1 << 13 );
+
+  /* Cycle the RGB LED through a pattern of colors */
+  #define DELAY_CYCLES ( 50000 )
+  while( 1 )
+  {
+    /* Green on (Green) */
+    GPIOA->ODR &= ~( 0x1 << 1 );
+    delay_cycles( DELAY_CYCLES );
+    /* Red on (Yellow) */
+    GPIOC->ODR &= ~( 0x1 << 13 );
+    delay_cycles( DELAY_CYCLES );
+    /* Blue on (White) */
+    GPIOA->ODR &= ~( 0x1 << 2 );
+    delay_cycles( DELAY_CYCLES );
+    /* Green off (Purple) */
+    GPIOA->ODR |=  ( 0x1 << 1 );
+    delay_cycles( DELAY_CYCLES );
+    /* Red off (Blue) */
+    GPIOC->ODR |=  ( 0x1 << 13 );
+    delay_cycles( DELAY_CYCLES );
+    /* Blue off (Off) */
+    GPIOA->ODR |=  ( 0x1 << 2 );
+    delay_cycles( DELAY_CYCLES );
+  }
+  return 0;
+}