Skip to content

Commit

Permalink
Merge branch 'build-sys' of github.com:ucb-bar/Baremetal-IDE into bui…
Browse files Browse the repository at this point in the history
…ld-sys
  • Loading branch information
T-K-233 committed Sep 16, 2024
2 parents 6230b29 + 50364e5 commit d1c9347
Show file tree
Hide file tree
Showing 98 changed files with 996 additions and 1,147 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/make-examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,10 @@ jobs:
export PATH="$RISCV/bin:$PATH"
cmake . -S ./ -B ./build/ -D CMAKE_BUILD_TYPE=Debug -D CMAKE_TOOLCHAIN_FILE=./riscv-gcc.cmake
cmake --build ./build/ --target app
- name: Make for BearlyML
run: |
export RISCV="$GITHUB_WORKSPACE/riscv64-unknown-toolchain"
export PATH="$RISCV/bin:$PATH"
cmake . -S ./ -B ./build/ -D CMAKE_BUILD_TYPE=Debug -D CMAKE_TOOLCHAIN_FILE=./riscv-gcc.cmake -D CHIP=bearlyml
cmake --build ./build/ --target app
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
# Build instructions:
# cmake -S ./ -B ./build/ -D CMAKE_BUILD_TYPE=Debug -D CMAKE_TOOLCHAIN_FILE=./riscv-gcc.cmake
# cmake --build ./build/ --target all
#
# Building on Windows:
# cmake . -S ./ -B ./build/ -G "Unix Makefiles" -D CMAKE_BUILD_TYPE=Debug -D CMAKE_TOOLCHAIN_FILE=./riscv-gcc.cmake
# cmake --build ./build/ --target all
# Cleaning:
# cmake --build ./build/ --target clean
# Install:
Expand All @@ -23,6 +27,8 @@ project(baremetal-ide LANGUAGES ASM C CXX)
option(BAREMETAL_BUILD_RISCV "Build for RISC-V platform" ON )
option(BAREMETAL_BUILD_X86 "Build for x86 platform" OFF )

option(CHIP "Build for a specific platform" OFF )


#################################
# Toolchain Targets
Expand All @@ -46,7 +52,8 @@ set(SPECS "nosys.specs")
set(SPEC_FLAGS -specs=${SPECS})

# linker script
set(LINKER_SCRIPT "${CMAKE_SOURCE_DIR}/glossy/glossy.ld")
# set(LINKER_SCRIPT "${CMAKE_SOURCE_DIR}/glossy/glossy.ld")
set(LINKER_SCRIPT "${CMAKE_SOURCE_DIR}/platform/bearlyml/bearlyml.ld")


add_compile_options(-O1)
Expand Down
4 changes: 1 addition & 3 deletions app/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,9 @@ void APP_init() {
void APP_main() {
uint64_t mhartid = READ_CSR("mhartid");

// sleep(1);
printf("Hello world from hart %d: %d\n", mhartid, counter);
// sleep(1);
printf("Hello world from hart %d: %d\n", mhartid, counter);

sleep(1);
}
/* USER CODE END PUC */

Expand Down
6 changes: 3 additions & 3 deletions driver/common/hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
* @date 2023-05-20
*/

#ifndef __RV_H
#define __RV_H
#ifndef __HAL_H
#define __HAL_H

#include <stdint.h>
#include <stddef.h>
Expand Down Expand Up @@ -65,4 +65,4 @@ typedef enum {
TIMEOUT
} Status;

#endif /* __RV_H */
#endif /* __HAL_H */
5 changes: 0 additions & 5 deletions driver/rocket-chip-blocks/gpio/gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ typedef struct {
} GPIO_InitTypeDef;


#ifndef GPIOA_BASE
#define GPIOA_BASE 0x10010000U
#define GPIOA ((GPIOA_TypeDef *)GPIOA_BASE)
#endif

void GPIO_init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_init, GPIO_Pin pin);

uint8_t GPIO_readPin(GPIO_TypeDef *GPIOx, GPIO_Pin pin);
Expand Down
29 changes: 15 additions & 14 deletions driver/rocket-chip/clint/clint.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,29 @@

#include "clint.h"

uint64_t CLINT_getTime() {

uint64_t CLINT_getTime(CLINT_TypeDef *clint) {
#if RISCV_XLEN == 32
uint32_t time_lo;
uint32_t time_hi;
uint32_t time_lo;
uint32_t time_hi;

do {
time_hi = *((__IO uint32_t *)(&CLINT->MTIME) + 1);
time_lo = *((__IO uint32_t *)(&CLINT->MTIME));
} while (*((__IO uint32_t *)(&CLINT->MTIME) + 1) != time_hi);
do {
time_hi = *((__IO uint32_t *)((clint->MTIME) + 1);
time_lo = *((__IO uint32_t *)(clint->MTIME));
} while (*((__IO uint32_t *)(clint->MTIME) + 1) != time_hi);

return (((uint64_t)time_hi) << 32U) | time_lo;
return (((uint64_t)time_hi) << 32U) | time_lo;
#else
return CLINT->MTIME;
return clint->MTIME;
#endif
}

void CLINT_setTimerInterruptTarget(uint32_t hartid, uint64_t time) {
void CLINT_setTimerInterruptTarget(CLINT_TypeDef *clint, uint32_t hartid, uint64_t time) {
#if RISCV_XLEN == 32
*((__IO uint32_t *)(&CLINT->MTIMECMP[hartid] + 1)) = 0xFFFFFFFF;
*((__IO uint32_t *)(&CLINT->MTIMECMP[hartid])) = (uint32_t)time;
*((__IO uint32_t *)(&CLINT->MTIMECMP[hartid])) = (uint32_t)(time >> 32);
*((__IO uint32_t *)(clint->MTIMECMP[hartid] + 1)) = 0xFFFFFFFF;
*((__IO uint32_t *)(clint->MTIMECMP[hartid])) = (uint32_t)time;
*((__IO uint32_t *)(clint->MTIMECMP[hartid])) = (uint32_t)(time >> 32);
#else
CLINT->MTIMECMP[hartid] = time;
clint->MTIMECMP[hartid] = time;
#endif
}
18 changes: 6 additions & 12 deletions driver/rocket-chip/clint/clint.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,12 @@ typedef struct {
} CLINT_TypeDef;


#ifndef CLINT_BASE
#define CLINT_BASE 0x02000000U
#define CLINT ((CLINT_TypeDef *)CLINT_BASE)
#endif


static inline void CLINT_clearSoftwareInterrupt(uint32_t hartid) {
CLEAR_BITS(CLINT->MSIP[hartid], 1U);
static inline void CLINT_clearSoftwareInterrupt(CLINT_TypeDef *clint, uint32_t hartid) {
CLEAR_BITS(clint->MSIP[hartid], 1U);
}

static inline void CLINT_triggerSoftwareInterrupt(uint32_t hartid) {
SET_BITS(CLINT->MSIP[hartid], 1U);
static inline void CLINT_triggerSoftwareInterrupt(CLINT_TypeDef *clint, uint32_t hartid) {
SET_BITS(clint->MSIP[hartid], 1U);
}

/**
Expand All @@ -36,7 +30,7 @@ static inline void CLINT_triggerSoftwareInterrupt(uint32_t hartid) {
*
* @return uint64_t current time
*/
uint64_t CLINT_getTime();
uint64_t CLINT_getTime(CLINT_TypeDef *clint);

/**
* @brief Set target interrupt time
Expand All @@ -46,7 +40,7 @@ uint64_t CLINT_getTime();
* @param hartid hart ID
* @param time time to set
*/
void CLINT_setTimerInterruptTarget(uint32_t hartid, uint64_t time);
void CLINT_setTimerInterruptTarget(CLINT_TypeDef *clint, uint32_t hartid, uint64_t time);


#ifdef __cplusplus
Expand Down
Empty file removed examples/arty/uart/Makefile
Empty file.
49 changes: 0 additions & 49 deletions examples/arty/uart/src/main.c

This file was deleted.

82 changes: 82 additions & 0 deletions examples/blinky/inc/main.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : main.h
* @brief : Header for main.c file.
* This file contains the common defines of the application.
******************************************************************************
* @attention
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H
#define __MAIN_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <time.h>

#include "riscv.h"


/**
* This section controls which peripheral device is included in the application program.
* To save the memory space, the unused peripheral device can be commented out.
*/
// #include "hal_core.h"
// #include "hal_clint.h"
// #include "hal_gpio.h"
// #include "hal_i2c.h"
// #include "hal_plic.h"
// #include "hal_uart.h"

/* USER CODE END Includes */

/* Private defines -----------------------------------------------------------*/
/* USER CODE BEGIN Private defines */

/* USER CODE END Private defines */

/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */

/* USER CODE END ET */

/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */

/* USER CODE END EC */

/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */

/* USER CODE END EM */

/* Exported functions prototypes ---------------------------------------------*/
/* USER CODE BEGIN EFP */
void APP_init();
void APP_main();
/* USER CODE END EFP */

#ifdef __cplusplus
}
#endif

#endif /* __MAIN_H */
Loading

0 comments on commit d1c9347

Please sign in to comment.