An Operating system built for the Pchip.
Install the rust programming language from the official website
cargo run
This will launch a serial port on your machine, and you will need to use a serial port console to connect to it.
If you wish to try the OS directly on your terminal, edit .cargo/config.toml
: change pty
to stdio
on line 7.
The OS will run on the Pchip, but be aware that due to the various bug on the Pchip, the OS will not run correctly as of now.
ue to the size limit of BRAM (4k), PCHIP OS doesn't fit in BRAM anymore. If you wish to follow these steps, make sure you delete some code so that it is smaller than 4kb.
-
Change the linker script.
In
.cargo/config.toml
, change therustflags
to use the pchip linker file:rustflags = ['-Clink-arg=-Tsrc/lds/pchip.lds', '-Ctarget-feature=-c']
-
Change the driver
In
src/uart.rs
, change all instances ofvirt_uart
toaxi_uart_lite
-
generate the
.mem
filesmake gen_bram
This will create 4
.mem
files under the project root. These files can then be written into BRAM of the Bitstream using the Vivado tools. This is the same as thesd.c
project. There should be aMakefile
that does the rest of the conversions. Please ask Suezuku-San for details.
Warning: I have not tried this as a bootloader isn't available on pchip yet.
Make sure your bootloader puts the code at address 0x8000_0000
. If so, you should be able to keep using the virt.ld
linker file. Otherwise you will need to write your own linker file. You will still need to change the UART driver as described above.
After the OS is booted, the following message is shown.
Hello world!
File status: false
Please select an Operation:
h. Show this help message
0. Trigger Breakpoint
After uploading a file/executable, the complete list will be shown
Please select an Operation:
h. Show this help message
0. Trigger Breakpoint
1. Recieve a file
2. Execute
3. Show file in plain text
4. Show file in hex
5. Print value at memory address
This is tested with minicom
on Linux.
- Press
1
to initiate Xmodem Receiver on PCHIP OS. You should NOT press any keys on your keyboard, as Xmodem will be listening for a Xmodem Sender on UART. - To initiate Xmodem Sending in
minicom
, pressctrl-a
and thens
. SelectXmodem
in the pop up window, and then choose the file you want to send. The transfer will start shortly. - After the file is sent, PCHIP OS will show the checksum of the received file. To verify the cksum on your host machine, you can execute
cksum [FILENAME]
in your terminal. If the checksum is correct, enteryes
and the transfer will be complete.
Compile the program with:
- Base address at 0x9000_0000.
- Convert to binary format (elf is default)
- Call syscall 0 to exit the program
C example:
-
Write your program.
-
Add a system call at the end of the program. The system call will exit from the program and return control to the OS. Code for the system call:
asm volatile ("li a0, 0; ecall;");
If you want to add a breakpoint in your program, insert this line
asm volatile ("ebreak;");
-
Compile the program with base address of
0x90000000
and convert to binary.Example Makefile:
CROSSCOMPILE?=riscv64-unknown-elf- CC=${CROSSCOMPILE}gcc LD=${CROSSCOMPILE}ld OBJCOPY=${CROSSCOMPILE}objcopy CFLAGS=-ffreestanding LDFLAGS=-Ttext=0x90000000 -nostdlib main.bin: main.elf $(OBJCOPY) -S -O binary $^ $@ main.elf: main.o $(LD) $(LDFLAGS) -o $@ $^ %.o: %.c $(CC) $(CFLAGS) -c -o $@ $< clean:: rm *.o *.elf *.bin
That's it! Compile your program and upload the .bin file to run in PCHIP OS!