Skip to content

Commit

Permalink
Merge pull request #2 from YuzukiHD/v0.2.0
Browse files Browse the repository at this point in the history
bump to verision 2.0
  • Loading branch information
YuzukiTsuru committed Dec 25, 2023
2 parents 6360f49 + 1d08ca7 commit 66ced8a
Show file tree
Hide file tree
Showing 252 changed files with 11,873 additions and 1,307 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/CMake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ name: CMake Build Test

on:
push:
branches: [ "main" ]
branches: [ "main", "v0.2.0" ]
pull_request:
branches: [ "main" ]
branches: [ "main", "v0.2.0" ]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
Expand All @@ -28,7 +28,7 @@ jobs:
- name: Configure CMake arm-none-eabi
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build-arm-none-eabi -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
run: cmake -B ${{github.workspace}}/build-arm-none-eabi -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_BOARD_FILE=tinyvision.cmake

- name: Build arm-none-eabi
# Build your program with the given configuration
Expand All @@ -37,7 +37,7 @@ jobs:
- name: Configure CMake arm-linux-gnueabihf
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build-arm-linux-gnueabihf -DCROSS_COMPILE=arm-linux-gnueabihf- -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
run: cmake -B ${{github.workspace}}/build-arm-linux-gnueabihf -DCROSS_COMPILE=arm-linux-gnueabihf- -DCMAKE_BOARD_FILE=tinyvision.cmake -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}

- name: Build arm-linux-gnueabihf
# Build your program with the given configuration
Expand All @@ -46,7 +46,7 @@ jobs:
- name: Configure CMake arm-linux-gnueabi
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build-arm-linux-gnueabi -DCROSS_COMPILE=arm-linux-gnueabi- -DENABLE_HARDFP=OFF -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
run: cmake -B ${{github.workspace}}/build-arm-linux-gnueabi -DCROSS_COMPILE=arm-linux-gnueabi- -DCMAKE_BOARD_FILE=tinyvision.cmake -DENABLE_HARDFP=OFF -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}

- name: Build arm-linux-gnueabi
# Build your program with the given configuration
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
build/
test/
tools/*.bin
mksunxi
mksunxi
.vscode/settings.json
158 changes: 84 additions & 74 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,39 +1,43 @@
# SPDX-License-Identifier: Apache-2.0

# Specify the minimum required version of CMake
cmake_minimum_required(VERSION 3.10)

# Options
# Define the path to the board loader files
set(BOARD_FLOADER_PATH ${CMAKE_SOURCE_DIR}/cmake/board/)

# By setting ENABLE_HARDFP to ON, it indicates that the project is configured
# to utilize hard floating-point operations when applicable. This can be beneficial
# in scenarios where performance gains from hardware acceleration are desired.
option(ENABLE_HARDFP "Enable hardware floating-point operations" ON)

set(CROSS_COMPILE "arm-none-eabi-")

set(CROSS_COMPILE ${CROSS_COMPILE} CACHE STRING "CROSS_COMPILE Toolchain")

set(CMAKE_C_COMPILER "${CROSS_COMPILE}gcc")
set(CMAKE_CXX_COMPILER "${CROSS_COMPILE}g++")

if(ENABLE_HARDFP)
set(CMAKE_COMMON_FLAGS "-nostdlib -g -ggdb -O3 -mcpu=cortex-a7 -mthumb-interwork -mthumb -mno-unaligned-access -mfpu=neon-vfpv4 -mfloat-abi=hard")
# Check if the CMAKE_BOARD_FILE variable is defined
if(CMAKE_BOARD_FILE)
# Set the value of CMAKE_BOARD_FILE and include the file
set(CMAKE_BOARD_FILE ${BOARD_FLOADER_PATH}${CMAKE_BOARD_FILE})
message(STATUS "CMAKE_BOARD_FILE = ${CMAKE_BOARD_FILE}")
include(${CMAKE_BOARD_FILE})
else()
set(CMAKE_COMMON_FLAGS "-nostdlib -g -ggdb -O3 -mcpu=cortex-a7 -mthumb-interwork -mthumb -mno-unaligned-access -mfpu=neon-vfpv4 -mfloat-abi=softfp")
set(CMAKE_AVALIABLE_BOARD "")
file(GLOB FILE_LIST "${BOARD_FLOADER_PATH}/*.cmake")
foreach(FILE_PATH ${FILE_LIST})
get_filename_component(BOARD_FILE_NAME ${FILE_PATH} NAME)
set(CMAKE_AVALIABLE_BOARD "${CMAKE_AVALIABLE_BOARD}\n ${BOARD_FILE_NAME}")
endforeach()
message(FATAL_ERROR
"You need to select target Board:"
"${CMAKE_AVALIABLE_BOARD}"
"\nUse -DCMAKE_BOARD_FILE=xxx.cmake to define target board"
"\neg:"
"\n cmake -DCMAKE_BOARD_FILE=tinyvision.cmake .."
)
endif()

set(CMAKE_C_DISABLE_WARN_FLAGS "-Wno-int-to-pointer-cast -Wno-implicit-function-declaration -Wno-discarded-qualifiers")
set(CMAKE_CXX_DISABLE_WARN_FLAGS "-Wno-int-to-pointer-cast")

# Set compilation flags
set(CMAKE_C_FLAGS "${CMAKE_C_DISABLE_WARN_FLAGS} ${CMAKE_C_FLAGS} ${CMAKE_COMMON_FLAGS}" CACHE STRING "c flags")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_DISABLE_WARN_FLAGS} ${CMAKE_CXX_FLAGS} ${CMAKE_COMMON_FLAGS}" CACHE STRING "c++ flags")
set(CMAKE_ASM_FLAGS "${CMAKE_C_DISABLE_WARN_FLAGS} ${CMAKE_ASM_FLAGS} ${CMAKE_COMMON_FLAGS}" CACHE STRING "asm flags")

# Set Version, Release need cmake
# Define the major and minor version numbers of the project
set(PROJECT_VERSION_MAJOR 0)
set(PROJECT_VERSION_MINOR 0)
set(PROJECT_VERSION_MINOR 2)

# use git version as library version
# Use Git commands to get the Git version and hash values of the project
find_package(Git QUIET)
if (Git_FOUND AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
execute_process(
Expand All @@ -55,19 +59,24 @@ else ()
set(PROJECT_GIT_HASH "")
endif ()

# Define the project name and languages used
project(SyterKit C CXX ASM)

# Include other CMake modules
include(cmake/add_syterkit_app.cmake)
include(ExternalProject)

# Get the name of the compiler
string(SUBSTRING ${CMAKE_C_COMPILER} 1 -1 COMPILER_NAME)
string(REGEX REPLACE ".*/" "" COMPILER_NAME ${COMPILER_NAME})

# Configure file as required
configure_file(
"${PROJECT_SOURCE_DIR}/config.h.in"
"${PROJECT_BINARY_DIR}/config.h"
)

# Create an external project and build it
ExternalProject_Add(
mksunxi
PREFIX mksunxi
Expand All @@ -78,74 +87,75 @@ ExternalProject_Add(
BUILD_IN_SOURCE 1
)

# Set tools required for the build process
set(CMAKE_AR "${CROSS_COMPILE}ar")
set(CMAKE_OBJCOPY "${CROSS_COMPILE}objcopy")
set(CMAKE_SIZE "${CROSS_COMPILE}size")

# Define the path to the mksunxi tool
set(CMAKE_MKSUNXI "${PROJECT_SOURCE_DIR}/tools/mksunxi")

set(LINK_SCRIPT_FEL ${CMAKE_SOURCE_DIR}/link/link_elf.ld)
set(LINK_SCRIPT_BIN ${CMAKE_SOURCE_DIR}/link/link_bin.ld)
# Define the paths to the linker scripts
set(LINK_SCRIPT_FEL ${PROJECT_BINARY_DIR}/link_elf.ld)
set(LINK_SCRIPT_BIN ${PROJECT_BINARY_DIR}/link_bin.ld)

# If the CONFIG_ARCH_ARM32 variable is defined, execute the following content
if (CONFIG_ARCH_ARM32)
set(ARCH_INCLUDE include/arch/arm32)

set(ARCH_START_ADDRESS "${ARCH_BIN_START_ADDRESS}")
set(ARCH_SRAM_LENGTH "${ARCH_BIN_SRAM_LENGTH}")

configure_file(
"${PROJECT_SOURCE_DIR}/link/arm32/link.ld"
"${PROJECT_BINARY_DIR}/link_bin.ld"
)

set(ARCH_START_ADDRESS "${ARCH_FEL_START_ADDRESS}")
set(ARCH_SRAM_LENGTH "${ARCH_FEL_SRAM_LENGTH}")

configure_file(
"${PROJECT_SOURCE_DIR}/link/arm32/link.ld"
"${PROJECT_BINARY_DIR}/link_elf.ld"
)
endif()

# If the CONFIG_ARCH_ARM32 variable is defined, execute the following content
if (CONFIG_ARCH_RISCV64)
set(ARCH_INCLUDE include/arch/riscv64)

set(ARCH_START_ADDRESS "${ARCH_BIN_START_ADDRESS}")
set(ARCH_SRAM_LENGTH "${ARCH_BIN_SRAM_LENGTH}")

configure_file(
"${PROJECT_SOURCE_DIR}/link/riscv64/link.ld"
"${PROJECT_BINARY_DIR}/link_bin.ld"
)

set(ARCH_START_ADDRESS "${ARCH_FEL_START_ADDRESS}")
set(ARCH_SRAM_LENGTH "${ARCH_FEL_SRAM_LENGTH}")

configure_file(
"${PROJECT_SOURCE_DIR}/link/riscv64/link.ld"
"${PROJECT_BINARY_DIR}/link_elf.ld"
)
endif()

# Specify the paths of the include files
include_directories(
include
include/cli
include/arch
include/drivers
include/reg
include/drivers/reg
include/lib/fatfs
include/lib/fdt
include/lib/elf
include/lib/ini
${ARCH_INCLUDE}
${PROJECT_BINARY_DIR}
)

add_library(SyterKit
# log
src/log/log.c
src/log/xformat.c
# string
src/string/string.c
src/string/memcpy.S
src/string/memset.S
src/string/memcmp.S
# cli
src/cli/commands.c
src/cli/history.c
src/cli/lineedit.c
src/cli/parse.c
src/cli/shell.c
# exception & common
src/exception.c
src/common.c
# src
src/jmp.c
src/uart.c
src/ctype.c
src/fdt_wrapper.c
src/smalloc.c
src/sstdlib.c
src/cache.S
# deiver
drivers/sys-clk.c
drivers/sys-dma.c
drivers/sys-gpio.c
drivers/sys-dram.c
drivers/sys-sdcard.c
drivers/sys-sdhci.c
drivers/sys-rproc.c
drivers/sys-spi.c
drivers/sys-spi-nand.c
drivers/sys-sid.c
drivers/sys-timer.c
drivers/sys-uart.c
drivers/sys-wdt.c
drivers/sys-rtc.c
drivers/sys-i2c.c
)

target_link_libraries(SyterKit gcc fdt)

# Add subdirectories and execute the appropriate CMakeLists.txt files
add_subdirectory(src)
add_subdirectory(lib)

add_subdirectory(app)
add_subdirectory(board)
Binary file removed assets/post/README/image-20231206211759386.png
Binary file not shown.
Binary file removed assets/post/README/image-20231206212123866.png
Binary file not shown.
Binary file removed assets/post/README/image-20231206212457356.png
Binary file not shown.
Binary file removed assets/post/README/image-20231206212627062.png
Binary file not shown.
Binary file removed assets/post/README/image-20231206213445553.png
Binary file not shown.
13 changes: 13 additions & 0 deletions board/100ask-t113i/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
set(APP_COMMON_SOURCE
${CMAKE_CURRENT_SOURCE_DIR}/start.S
${CMAKE_CURRENT_SOURCE_DIR}/board.c
${CMAKE_CURRENT_SOURCE_DIR}/eabi_compat.c
)

add_subdirectory(hello_world)

add_subdirectory(sys_info)

add_subdirectory(syter_boot)

add_subdirectory(load_c906)
File renamed without changes.
109 changes: 109 additions & 0 deletions board/100ask-t113i/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <types.h>

#include <log.h>

#include <common.h>

#include <reg-ncat.h>
#include <sys-clk.h>

#include <mmu.h>

#include <sys-gpio.h>
#include <sys-sdcard.h>
#include <sys-dram.h>
#include <sys-spi.h>
#include <sys-uart.h>

sunxi_serial_t uart_dbg = {
.base = SUNXI_UART0_BASE,
.id = 0,
.gpio_tx = {GPIO_PIN(GPIO_PORTB, 8), GPIO_PERIPH_MUX6},
.gpio_rx = {GPIO_PIN(GPIO_PORTB, 9), GPIO_PERIPH_MUX6},
};

sunxi_spi_t sunxi_spi0 = {
.base = SUNXI_SPI0_BASE,
.id = 0,
.clk_rate = 75 * 1000 * 1000,
.gpio_cs = {GPIO_PIN(GPIO_PORTC, 1), GPIO_PERIPH_MUX4},
.gpio_sck = {GPIO_PIN(GPIO_PORTC, 0), GPIO_PERIPH_MUX4},
.gpio_mosi = {GPIO_PIN(GPIO_PORTC, 2), GPIO_PERIPH_MUX4},
.gpio_miso = {GPIO_PIN(GPIO_PORTC, 3), GPIO_PERIPH_MUX4},
.gpio_wp = {GPIO_PIN(GPIO_PORTC, 4), GPIO_PERIPH_MUX4},
.gpio_hold = {GPIO_PIN(GPIO_PORTC, 5), GPIO_PERIPH_MUX4},
};

sdhci_t sdhci0 = {
.name = "sdhci0",
.reg = (sdhci_reg_t *) SUNXI_SMHC0_BASE,
.voltage = MMC_VDD_27_36,
.width = MMC_BUS_WIDTH_4,
.clock = MMC_CLK_50M,
.removable = 0,
.isspi = FALSE,
.gpio_clk = {GPIO_PIN(GPIO_PORTF, 2), GPIO_PERIPH_MUX2},
.gpio_cmd = {GPIO_PIN(GPIO_PORTF, 3), GPIO_PERIPH_MUX2},
.gpio_d0 = {GPIO_PIN(GPIO_PORTF, 1), GPIO_PERIPH_MUX2},
.gpio_d1 = {GPIO_PIN(GPIO_PORTF, 0), GPIO_PERIPH_MUX2},
.gpio_d2 = {GPIO_PIN(GPIO_PORTF, 5), GPIO_PERIPH_MUX2},
.gpio_d3 = {GPIO_PIN(GPIO_PORTF, 4), GPIO_PERIPH_MUX2},
};

sdhci_t sdhci2 = {
.name = "sdhci2",
.reg = (sdhci_reg_t *) SUNXI_SMHC2_BASE,
.voltage = MMC_VDD_27_36,
.width = MMC_BUS_WIDTH_4,
.clock = MMC_CLK_50M,
.removable = 0,
.isspi = FALSE,
.gpio_clk = {GPIO_PIN(GPIO_PORTC, 2), GPIO_PERIPH_MUX3},
.gpio_cmd = {GPIO_PIN(GPIO_PORTC, 3), GPIO_PERIPH_MUX3},
.gpio_d0 = {GPIO_PIN(GPIO_PORTC, 6), GPIO_PERIPH_MUX3},
.gpio_d1 = {GPIO_PIN(GPIO_PORTC, 5), GPIO_PERIPH_MUX3},
.gpio_d2 = {GPIO_PIN(GPIO_PORTC, 4), GPIO_PERIPH_MUX3},
.gpio_d3 = {GPIO_PIN(GPIO_PORTC, 7), GPIO_PERIPH_MUX3},
};

dram_para_t dram_para = {
.dram_clk = 792,
.dram_type = 3,
.dram_zq = 0x7b7bfb,
.dram_odt_en = 0x01,
.dram_para1 = 0x000010d2,
.dram_para2 = 0,
.dram_mr0 = 0x1c70,
.dram_mr1 = 0x42,
.dram_mr2 = 0x18,
.dram_mr3 = 0,
.dram_tpr0 = 0x004a2195,
.dram_tpr1 = 0x02423190,
.dram_tpr2 = 0x0008b061,
.dram_tpr3 = 0xb4787896,// unused
.dram_tpr4 = 0,
.dram_tpr5 = 0x48484848,
.dram_tpr6 = 0x00000048,
.dram_tpr7 = 0x1620121e,// unused
.dram_tpr8 = 0,
.dram_tpr9 = 0,// clock?
.dram_tpr10 = 0,
.dram_tpr11 = 0x00770000,
.dram_tpr12 = 0x00000002,
.dram_tpr13 = 0x34050100,
};

void clean_syterkit_data(void) {
/* Disable MMU, data cache, instruction cache, interrupts */
arm32_mmu_disable();
printk(LOG_LEVEL_INFO, "disable mmu ok...\n");
arm32_dcache_disable();
printk(LOG_LEVEL_INFO, "disable dcache ok...\n");
arm32_icache_disable();
printk(LOG_LEVEL_INFO, "disable icache ok...\n");
arm32_interrupt_disable();
printk(LOG_LEVEL_INFO, "free interrupt ok...\n");
}
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 66ced8a

Please sign in to comment.