Skip to content

Commit

Permalink
[support] v3s basic and Stop development
Browse files Browse the repository at this point in the history
  • Loading branch information
YuzukiTsuru committed Jan 3, 2024
1 parent ff30594 commit 0141f42
Show file tree
Hide file tree
Showing 27 changed files with 1,288 additions and 8 deletions.
4 changes: 4 additions & 0 deletions board/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@ endif()

if(CONFIG_BOARD_LONGANPI-4B)
add_subdirectory(longanpi-4b)
endif()

if(CONFIG_BOARD_BINGPI-M1)
add_subdirectory(bingpi-m1)
endif()
7 changes: 7 additions & 0 deletions board/bingpi-m1/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
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)
29 changes: 29 additions & 0 deletions board/bingpi-m1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# SyterKit Common

## start.S

This code snippet is an ARM assembly language program that includes initialization settings and exception handlers. Here's a breakdown of its functionalities:

1. Initialization Settings: It sets registers and writes specific values to configure the processor's working mode, interrupt enable, etc.

2. Set Vector Table: It writes the address of the vector table to the Vector Base Address Register, which is used for handling exceptions and interrupts.

3. Enable NEON/VFP Unit: It configures the processor to enable the NEON (Advanced SIMD) and VFP (Floating-Point) units.

4. Clear BSS Section: It zeroes out variables in the BSS section.

5. Disable Interrupts: It disables FIQ and IRQ interrupts and switches the processor to SVC32 mode.

6. Set Timer Frequency: It sets the timer frequency to 24M.

7. Call the main Function: It jumps to the main function to execute the main logic.

## eabi_compat.c

This code snippet appears to be providing implementations for the functions `abort`, `raise`, and `__aeabi_unwind_cpp_pr0`. Here's a breakdown of their functionalities:

1. `void abort(void)`: This function creates an infinite loop, causing the program to hang indefinitely. It is typically used to indicate a critical error or unrecoverable condition in a program.

2. `int raise(int signum)`: This function is a placeholder and always returns 0. In standard C, this function is used to raise a signal and initiate the corresponding signal handler. However, in this implementation, it does nothing and simply returns 0.

3. `void __aeabi_unwind_cpp_pr0(void)`: This is a dummy function that serves as a placeholder to avoid linker complaints. Its purpose is to satisfy the linker when using C++ exceptions and unwinding, but it does not contain any actual functionality.
76 changes: 76 additions & 0 deletions board/bingpi-m1/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <types.h>

#include <log.h>

#include <common.h>

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

#include <mmu.h>

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

sunxi_serial_t uart_dbg = {
.base = SUNXI_UART0_BASE,
.id = 0,
.gpio_tx = {GPIO_PIN(GPIO_PORTH, 9), GPIO_PERIPH_MUX5},
.gpio_rx = {GPIO_PIN(GPIO_PORTH, 10), GPIO_PERIPH_MUX5},
};

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");
}

void sunxi_serial_init_v3s(sunxi_serial_t *uart) {
uint32_t addr;
uint32_t val;

/* Open the clock gate for uart */
addr = CCU_BASE + CCU_BUS_CLK_GATE3;
val = read32(addr);
val |= 1 << uart->id;
write32(addr, val);

/* Deassert USART reset */
addr = CCU_BASE + CCU_BUS_SOFT_RST4;
val = read32(addr);
val |= 1 << (16 + uart->id);
write32(addr, val);

/* Config USART to 115200-8-1-0 */
addr = uart->base;
write32(addr + 0x04, 0x0);
write32(addr + 0x08, 0xf7);
write32(addr + 0x10, 0x0);
val = read32(addr + 0x0c);
val |= (1 << 7);
write32(addr + 0x0c, val);
write32(addr + 0x00, 0xd & 0xff);
write32(addr + 0x04, (0xd >> 8) & 0xff);
val = read32(addr + 0x0c);
val &= ~(1 << 7);
write32(addr + 0x0c, val);
val = read32(addr + 0x0c);
val &= ~0x1f;
val |= (0x3 << 0) | (0 << 2) | (0x0 << 3);
write32(addr + 0x0c, val);

/* Config uart TXD and RXD pins */
sunxi_gpio_init(uart->gpio_tx.pin, uart->gpio_tx.mux);
sunxi_gpio_init(uart->gpio_rx.pin, uart->gpio_rx.mux);
}
14 changes: 14 additions & 0 deletions board/bingpi-m1/eabi_compat.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* SPDX-License-Identifier: Apache-2.0 */

void abort(void) {
while (1)
;
}

int raise(int signum) {
return 0;
}

/* Dummy function to avoid linker complaints */
void __aeabi_unwind_cpp_pr0(void) {
}
5 changes: 5 additions & 0 deletions board/bingpi-m1/hello_world/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SPDX-License-Identifier: Apache-2.0

add_syterkit_app(helloworld
main.c
)
20 changes: 20 additions & 0 deletions board/bingpi-m1/hello_world/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* SPDX-License-Identifier: Apache-2.0 */

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <types.h>

#include <log.h>

extern sunxi_serial_t uart_dbg;

int main(void) {
sunxi_serial_init_v3s(&uart_dbg);

sunxi_clk_init();

printk(LOG_LEVEL_INFO, "Hello World!\n");

return 0;
}
Loading

0 comments on commit 0141f42

Please sign in to comment.