Add test
This commit is contained in:
parent
d9fc1f2062
commit
4336994571
14
flake.nix
14
flake.nix
|
@ -49,6 +49,20 @@
|
||||||
default = self.packages.${system}.smi;
|
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;
|
formatter = pkgs.nixfmt-rfc-style;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
BIN
tests/test-upstream.out
Executable file
BIN
tests/test-upstream.out
Executable file
Binary file not shown.
31
tests/test.c
Normal file
31
tests/test.c
Normal file
|
@ -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;
|
||||||
|
}
|
Loading…
Reference in a new issue