diff --git a/flake.nix b/flake.nix index 9fe1350..3f46fc4 100644 --- a/flake.nix +++ b/flake.nix @@ -49,6 +49,20 @@ default = self.packages.${system}.smi; }; + checks = { + simple = + pkgs.runCommand "test" + { + # Goes up to 7 + NIX_DEBUG = 0; + } + '' + mkdir -p $out + ${self.packages.${system}.tt-gcc}/bin/riscv32-unknown-elf-gcc ${./tests/test.c} -o $out/test + ${self.packages.${system}.tt-gcc}/bin/riscv32-unknown-elf-gcc -mblackhole ${./tests/test.c} -o $out/test-wormhole + ''; + }; + formatter = pkgs.nixfmt-rfc-style; } ); diff --git a/tests/test-upstream.out b/tests/test-upstream.out new file mode 100755 index 0000000..76359cc Binary files /dev/null and b/tests/test-upstream.out differ diff --git a/tests/test.c b/tests/test.c new file mode 100644 index 0000000..a5ac9d2 --- /dev/null +++ b/tests/test.c @@ -0,0 +1,31 @@ +#define GPIO_BASE (0x48000000U) // Base address for GPIO port (e.g., GPIOA on STM32) +#define RCC_BASE (0x40021000U) // Base address for RCC (Reset and Clock Control) + +#define RCC_AHB2ENR (*(volatile unsigned int *)(RCC_BASE + 0x4C)) +#define GPIOA_MODER (*(volatile unsigned int *)(GPIO_BASE + 0x00)) +#define GPIOA_ODR (*(volatile unsigned int *)(GPIO_BASE + 0x14)) + +#define LED_PIN 5 // Assume the LED is connected to GPIO pin 5 + +void delay(volatile unsigned int count) { + while (count--); +} + +int main(void) { + // Enable the clock for GPIOA + RCC_AHB2ENR |= (1 << 0); // Enable GPIOA clock + + // Set GPIOA pin 5 to output mode (01) + GPIOA_MODER &= ~(3 << (LED_PIN * 2)); // Clear mode bits for pin 5 + GPIOA_MODER |= (1 << (LED_PIN * 2)); // Set mode to 01 (output) + + while (1) { + // Toggle the LED + GPIOA_ODR ^= (1 << LED_PIN); + + // Delay + delay(100000); + } + + return 0; +}