f GNU Toolchain Setup & Bare Metal RISC V Program on emulSiv(Ubuntu VmWare demonstration).
Автор: Abdul
Загружено: 2025-10-30
Просмотров: 26
Описание:
🎓 University of Liberal Arts Bangladesh (ULAB)
Course: Microcontroller and Processor
Student:Abdul Aziz Faisal
ID: 233014055
Assignment Topic:
Setup GNU Toolchain for emulsiV and demonstrate Assembler, C Compiler, Linker, and HEX conversion steps.
All steps done in Ubuntu (VirtualBox on Windows).
---
🧩 Steps Demonstrated:
1️⃣ Setup GNU RISC-V Toolchain (gcc-riscv64-unknown-elf)
2️⃣ Using the assembler
3️⃣ Using the C compiler
4️⃣ Using the linker
5️⃣ Converting ELF to HEX
6️⃣ Running the HEX file in emulsiV simulator
---
📂 Source Files Used in This Demonstration
(Required *.s, *.c, *.ld files)
👇👇👇
🧠 startup.s
----------------------------------------
.section vectors, "x"
.global __reset
__reset:
j start # reset jumps here (address 0)
__irq:
j irq_handler # interrupt vector (address 4)
.text
.align 4
.weak irq_handler
irq_handler:
mret # simple return
start:
la gp, __global_pointer
la sp, __stack_pointer
la t0, __bss_start
la t1, __bss_end
bgeu t0, t1, memclr_done
memclr:
sw zero, 0(t0)
addi t0, t0, 4
bltu t0, t1, memclr
memclr_done:
call main
j .
----------------------------------------
💻 main.c
----------------------------------------
#define TEXT_OUT (*(volatile char*)0xC0000000)
static void print(const char *s) {
while (*s) TEXT_OUT = *s++;
}
void main(void) {
print("Virgule says\n Hello from Ubuntu! \n");
}
----------------------------------------
📜 emulsiv.ld
----------------------------------------
ENTRY(__reset)
MEM_SIZE = 4K;
BITMAP_SIZE = 1K;
STACK_SIZE = 512;
SECTIONS {
. = 0x0;
.text : {
*(vectors)
*(.text*)
__text_end = .;
}
.rodata : { *(.rodata*) }
.data : { *(.data*) }
__global_pointer = ALIGN(4);
.bss ALIGN(4) : {
__bss_start = .;
(.bss COMMON)
__bss_end = ALIGN(4);
}
. = MEM_SIZE - STACK_SIZE;
.stack ALIGN(4) : {
__stack_start = .;
. += STACK_SIZE;
__stack_pointer = .;
}
. = MEM_SIZE;
.bitmap ALIGN(4) : {
__bitmap_start = .;
KEEP(*(bitmap))
}
__bitmap_end = __bitmap_start + BITMAP_SIZE;
}
----------------------------------------
---
⚙️ Build Commands Used:
riscv64-unknown-elf-gcc -march=rv32i -mabi=ilp32 -c -o startup.o startup.s
riscv64-unknown-elf-gcc -march=rv32i -mabi=ilp32 -ffreestanding -c -o main.o main.c
riscv64-unknown-elf-gcc -march=rv32i -mabi=ilp32 -nostdlib -T emulsiv.ld -o hello.elf startup.o main.o
riscv64-unknown-elf-objcopy -O ihex hello.elf hello.hex
---
🧰 Tools Used:
Ubuntu 22.04 LTS (inside VirtualBox)
GNU RISC-V Toolchain (gcc-riscv64-unknown-elf)
emulsiV Web Simulator: https://eseo-tech.github.io/emulsiV/
---
📎 Reference:
emulsiV Official Documentation – https://eseo-tech.github.io/emulsiV/doc/
#RISC-V #emulsiV #ULAB #Microcontroller #Processor #Ubuntu #VirtualBox #GNUtoolchain
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: