Skip to content

Commit

Permalink
Merge pull request #238 from VisorFolks/development
Browse files Browse the repository at this point in the history
  • Loading branch information
akashkollipara authored Feb 24, 2023
2 parents 0337379 + f743430 commit 511695e
Show file tree
Hide file tree
Showing 54 changed files with 1,125 additions and 293 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ Connect with us over VisorFolks discord server: < [**JOIN**](https://discord.gg/

### Supported Platforms

| Atmel | SiFive | STMicro | TI | Raspberry Pi |
| ---------- | ----------- | ----------- | ----------- | -------------|
| ATMega328P | FE310-G002 | Coming soon | Coming soon | Coming soon |
| ATMega2560 | | | | |
| Atmel | SiFive | STMicro | TI | Raspberry Pi |
| ---------- | ------------- | ----------- | ----------- | -------------|
| ATMega328P | FE310-G002 | Coming soon | Coming soon | Coming soon |
| ATMega2560 | QEMU SiFive-E | | | |

### Programming Languages
* asm/assembly
Expand Down
2 changes: 1 addition & 1 deletion mk/elf.mk
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ elf: $(ELF)
$(ELF): $(DEP_LIBS) $(DEP_OBJS) $(LD_SCRIPT) $(LD_SUPPLEMENT) | $$(SIZE)
@echo "Elf: Generating $(@F) ..."
$(LD) -dT $(LD_SCRIPT) $(addprefix -T , $(LD_SUPPLEMENT)) $(LD_FLAGS) \
-Map=$(@:.elf=.map) -o $@ $(filter %.o, $^) $(DEP_LIB_PATH) $(DEP_LIBS_ARG) -L $(TL) -lgcc
-Map=$(@:.elf=.map) -o $@ $(filter %.o, $^) $(DEP_LIB_PATH) $(DEP_LIBS_ARG) $(EXLIB_ARGS) -L $(TL) -lgcc
$(OD) -Dx -h --wide $@ > $(@:.elf=.lst)
$(OC) -O binary $@ $(@:.elf=.bin)
$(OC) -O ihex $@ $(@:.elf=.hex)
Expand Down
8 changes: 3 additions & 5 deletions mk/lint.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@

LT := $(shell which cppcheck)

LINT_FLAGS += --error-exitcode=1 --std=c11 \
--enable=warning,style,performance \
--enable=portability,information \
--enable=missingInclude -q \
LINT_FLAGS += --error-exitcode=25 --std=c11 \
--max-ctu-depth=12 --max-configs=12 \
--check-config
--enable=all -q -v \
--suppress=unusedFunction

--lint: $(DEP_SRCS)
ifeq ($(LT),)
Expand Down
24 changes: 17 additions & 7 deletions mk/picotool.mk
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ SILENT_LOGS := > cbuild.log 2> /dev/null
endif

P_TARGETS += elf2uf2
T_ALLOWLIST += get_picotool pt_clean install_pt_dep
T_ALLOWLIST += get_picotool clean_picotool install_pt_dep

get_picotool: $(PICO_TOOL) $(ELF2UF2)

Expand All @@ -30,36 +30,46 @@ $(PICO_TOOL): $(PICO_TOOL_BUILD)
cp $(PICO_TOOL_PATH)/build/picotool $@

$(PICO_TOOL_BUILD): $(PICO_SDK_PATH) $(PICO_TOOL_PATH)
@echo "Building picotool ..."
@echo "< ! > Building picotool ..."
cd $(PICO_TOOL_PATH) && mkdir -p build && \
cd build && export PICO_SDK_PATH=$(PICO_SDK_PATH) && \
cmake ../ $(SILENT_LOGS) \
&& make $(SILENT_LOGS)
@echo "< / > Done!"

$(ELF2UF2): $(PICO_SDK_PATH)
@echo "Building elf2uf2 ..."
@echo "< ! > Building elf2uf2 ..."
mkdir -p $(MISC_TOOLS)/temp
cd $(MISC_TOOLS)/temp; \
cmake $(PICO_SDK_PATH)/tools/elf2uf2 2>/dev/null >/dev/null; \
make >/dev/null 2>/dev/null
cp $(MISC_TOOLS)/temp/elf2uf2 $@
rm -rf $(MISC_TOOLS)/temp
@echo "< ! > Cleaning up build space ..."
rm -rf $(PICO_SDK_PATH) $(PICO_TOOL_PATH)
@echo "< / > Done!"

elf2uf2: $(ELF2UF2) elf
@echo "Generating $(notdir $(ELF:.elf=.uf2)) ..."
$(ELF2UF2) $(ELF) $(ELF:.elf=.uf2)
@echo "< / > Done!"

$(PICO_SDK_PATH):
@echo "Fetching PICO SDK ..."
@echo "< ! > Fetching PICO SDK ..."
git clone $(PICO_SDK_GIT) --quiet $@
@echo "< / > Done!"

$(PICO_TOOL_PATH):
@echo "Fetching PICO Tool ..."
@echo "< ! > Fetching PICO Tool ..."
git clone $(PICO_TOOL_GIT) --quiet $@
@echo "< / > Done!"

install_pt_dep:
@echo "Installing Dependencies ..."
@echo "< ! > Installing Dependencies ..."
@sudo apt-get install build-essential pkg-config libusb-1.0-0-dev -y -qq > /dev/null
@echo "< / > Done!"

pt_clean:
clean_picotool:
@echo "< ! > Removing picotools ..."
rm -rf $(PICO_SDK_PATH) $(PICO_TOOL_PATH) $(PICO_TOOL) $(ELF2UF2)
@echo "< / > Done!"
32 changes: 23 additions & 9 deletions mk/qemu.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,38 @@
# Organisation : Cyancore Core-Team
#

T_ALLOWLIST += get_qemu
T_ALLOWLIST += get_qemu clean_qemu

get_qemu: | $(TOOLS_ROOT)/qemu/ $(TOOLS_ROOT)/qemu/build/
QEMU_CHECKOUT := v7.2.0
QEMU_PATH := $(TOOLS_ROOT)/qemu
QEMU_BUILD_PATH := $(QEMU_PATH)/build
QEMU_OUT_PATH := $(TOOLS_ROOT)/cc_qemu
QEMU_TLIST := avr-softmmu,arm-softmmu,riscv32-softmmu

$(TOOLS_ROOT)/qemu/:
get_qemu: $(QEMU_OUT_PATH)

$(TOOLS_ROOT)/qemu:
@echo "< ! > Using qemu version: $(QEMU_CHECKOUT)"
@echo "< ! > Fetching qemu ..."
mkdir -p $(TOOLS_ROOT)
cd $(TOOLS_ROOT); git clone https://gitlab.com/qemu-project/qemu.git;
cd $@; git submodule init; git submodule update --recursive
cd $(TOOLS_ROOT); git clone https://gitlab.com/qemu-project/qemu.git --quiet;
cd $@; git checkout -b $(QEMU_CHECKOUT) $(QEMU_CHECKOUT) 1> /dev/null 2> /dev/null
@echo "< / > Done !"

$(TOOLS_ROOT)/qemu/build/: $(TOOLS_ROOT)/qemu/

$(QEMU_OUT_PATH): $(QEMU_PATH)
@echo "< ! > Building qemu ..."
@echo "< ? > Please be patient as this might take a while ..."
cd $<; ./configure
make -j $(N_JOBS) -C $<
cd $<; ./configure --prefix=$(QEMU_OUT_PATH) --target-list=$(QEMU_TLIST) 2> /dev/null 1> /dev/null
make -j $(N_JOBS) -C $< install 2> /dev/null 1> /dev/null
@echo "< ! > Cleaning up build space ..."
rm -rf $(QEMU_PATH)
@echo "< ! > Adding load_qemu alias to bashrc ..."
@echo "< ! > run 'load_qemu' before trying to launch qemu!"
echo "alias load_qemu='export PATH=\"\$$PATH\":$@/build/'" >> ~/.bashrc
echo "alias load_qemu='export PATH=\"\$$PATH\":$@/bin/'" >> ~/.bashrc
@echo "< / > Done !"

clean_qemu:
@echo "< ! > Removing cc-qemu installation ..."
rm -rf $(QEMU_OUT_PATH) $(QEMU_PATH)
@echo "< / > Done!"
3 changes: 1 addition & 2 deletions projects/demo_avr_cpp/project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,9 @@ void delay(unsigned long d)
asm volatile("nop");
}

static unsigned char i = 0;
EXPORT_C(void play())
{
static unsigned int i = 0;

wdog_guard(WDT_64MS, true, NULL);

/* call the toggle member of led object */
Expand Down
20 changes: 20 additions & 0 deletions projects/demo_qemu_sifive_e/build.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# CYANCORE LICENSE
# Copyrights (C) 2023, Cyancore Team
#
# File Name : build.mk
# Description : This file builds and gathers project properties
# Primary Author : Akash Kollipara [[email protected]]
# Organisation : Cyancore Core-Team
#

PROJECT_DIR := $(GET_PATH)

include $(PROJECT_DIR)/../demo.src/build.mk
include $(PROJECT_DIR)/config.mk

DIR := $(PROJECT_DIR)
include mk/obj.mk

aux_target:
make qemu_sifive_e_bl
20 changes: 20 additions & 0 deletions projects/demo_qemu_sifive_e/config.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# CYANCORE LICENSE
# Copyrights (C) 2023, Cyancore Team
#
# File Name : config.mk
# Description : This file consists of project config
# Primary Author : Akash Kollipara [[email protected]]
# Organisation : Cyancore Core-Team
#

COMPILER := gcc
TC_VER := 10.2.0
FAMILY := sifive
PLATFORM := qemu-sifive-e
STDLOG_MEMBUF := 0
BOOTMSGS := 0
EARLYCON_SERIAL := 1
CONSOLE_SERIAL := 1
OBRDLED_ENABLE := 1
TERRAKERN := 0
21 changes: 21 additions & 0 deletions projects/qemu_sifive_e_bl/build.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# CYANCORE LICENSE
# Copyrights (C) 2023, Cyancore Team
#
# File Name : build.mk
# Description : This file build project sources and specifies
# project properties
# Primary Author : Akash Kollipara [[email protected]]
# Organisation : Cyancore Core-Team
#

PROJECT_DIR := $(GET_PATH)

OPTIMIZATION := s

EXE_MODE := terravisor

include $(PROJECT_DIR)/config.mk

DIR := $(PROJECT_DIR)
include mk/obj.mk
21 changes: 21 additions & 0 deletions projects/qemu_sifive_e_bl/config.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# CYANCORE LICENSE
# Copyrights (C) 2023, Cyancore Team
#
# File Name : config.mk
# Description : This file consists of project config
# Primary Author : Akash Kollipara [[email protected]]
# Organisation : Cyancore Core-Team
#

COMPILER := gcc
TC_VER := 10.2.0
FAMILY := sifive
PLATFORM := qemu-sifive-e-bl
USE_FLOAT := 0
STDLOG_MEMBUF := 0
BOOTMSGS := 0
EARLYCON_SERIAL := 1
CONSOLE_SERIAL := 0
OBRDLED_ENABLE := 0
TERRAKERN := 0
40 changes: 40 additions & 0 deletions projects/qemu_sifive_e_bl/project.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* CYANCORE LICENSE
* Copyrights (C) 2023, Cyancore Team
*
* File Name : project.c
* Description : This file consists of project srouces
* Primary Author : Akash Kollipara [[email protected]]
* Organisation : Cyancore Core-Team
*/

#include <status.h>
#include <syslog.h>
#include <terravisor/bootstrap.h>
#include <arch.h>
#include <driver.h>
#include <interrupt.h>
#include <platform.h>

void no_program(void);
void plug()
{
bootstrap();
driver_setup_all();
syslog_stdout_enable();
link_interrupt(int_arch, 2, no_program);
syslog(info, "Bootloader!\n");
syslog(info, "Jumping to XIP...\n");
driver_exit_all();
arch_di();
platform_jump_to_user_code();
return;
}

void no_program()
{
driver_setup_all();
syslog(fail, "No User program found!\n");
plat_panic_handler();
}

20 changes: 8 additions & 12 deletions src/arch/avr/8/common_5x_6/terravisor/arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void arch_di_save_state(istate_t *sreg_i_backup)
arch_di();
}

void arch_ei_restore_state(istate_t *sreg_i_backup)
void arch_ei_restore_state(const istate_t *sreg_i_backup)
{
MMIO8(SREG+0x20) |= *sreg_i_backup;
}
Expand Down Expand Up @@ -81,16 +81,12 @@ void _NORETURN arch_panic_handler_callback()
if(!frame)
goto panic;
syslog_stdout_enable();
sysdbg("r0=%p\tr1=%p\tr2=%p\tr3=%p\tr4=%p\tr5=%p\n",
frame->r0, frame->r1, frame->r2, frame->r3, frame->r4, frame->r5);
sysdbg("r6=%p\tr7=%p\tr8=%p\tr9=%p\tr10=%p\tr11=%p\n",
frame->r6, frame->r7, frame->r8, frame->r9, frame->r10, frame->r11);
sysdbg("r12=%p\tr13=%p\tr14=%p\tr15=%p\tr16=%p\tr17=%p\n",
frame->r12, frame->r13, frame->r14, frame->r15, frame->r16, frame->r17);
sysdbg("r18=%p\tr19=%p\tr20=%p\tr21=%p\tr22=%p\tr23=%p\n",
frame->r18, frame->r19, frame->r20, frame->r21, frame->r22, frame->r23);
sysdbg("r24=%p\tr25=%p\tr26=%p\tr27=%p\tr28=%p\tr29=%p\n",
frame->r24, frame->r25, frame->r26, frame->r27, frame->r28, frame->r29);
sysdbg("r0=%p\tr1=%p\tr18=%p\tr19=%p\n",
frame->r0, frame->r1, frame->r18, frame->r19);
sysdbg("r20=%p\tr21=%p\tr22=%p\tr23=%p\n",
frame->r20, frame->r21, frame->r22, frame->r23);
sysdbg("r24=%p\tr25=%p\tr26=%p\tr27=%p\n",
frame->r24, frame->r25, frame->r26, frame->r27);
sysdbg("r30=%p\tr31=%p\tSP=%p\tSREG=%p\n",
frame->r30, frame->r31, frame, frame->sreg);
#if DEBUG==0
Expand All @@ -113,7 +109,7 @@ static cpu_sleep_t sleep_flag;
*/
bool arch_suspended_state_was(cpu_sleep_t state)
{
assert(state != resume);
assert((unsigned)state != resume);
if(!sleep_flag)
return false;
return (sleep_flag == state);
Expand Down
Loading

0 comments on commit 511695e

Please sign in to comment.