diff --git a/CMakeLists.txt b/CMakeLists.txt index 55182594..159185f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,8 @@ cmake_minimum_required(VERSION 3.10) include(ExternalProject) +set(CMAKE_SYSTEM_NAME Generic) + # Define the path to the board loader files set(BOARD_FLOADER_PATH ${CMAKE_SOURCE_DIR}/cmake/board/) # Define the path to the mksunxi tool @@ -81,16 +83,18 @@ configure_file( "${PROJECT_BINARY_DIR}/config.h" ) -# Create an external project and build it -ExternalProject_Add( - mksunxi - PREFIX mksunxi - SOURCE_DIR "${PROJECT_SOURCE_DIR}/tools" - INSTALL_COMMAND "" - CONFIGURE_COMMAND "" - BUILD_COMMAND make -C ${PROJECT_SOURCE_DIR}/tools - BUILD_IN_SOURCE 1 -) +if(NOT WIN32) + # Create an external project and build it + ExternalProject_Add( + mksunxi + PREFIX mksunxi + SOURCE_DIR "${PROJECT_SOURCE_DIR}/tools" + INSTALL_COMMAND "" + CONFIGURE_COMMAND "" + BUILD_COMMAND make -C ${PROJECT_SOURCE_DIR}/tools + BUILD_IN_SOURCE 1 + ) +endif() # Set tools required for the build process set(CMAKE_AR "${CROSS_COMPILE}ar") diff --git a/README.md b/README.md index 56acb2f1..4f32b95c 100644 --- a/README.md +++ b/README.md @@ -24,11 +24,13 @@ SyterKit is a bare-metal framework designed for development boards like TinyVisi ### Building SyterKit From Scratch -Building SyterKit is a straightforward process that only requires setting up the environment for compilation on a Linux operating system. The software packages required by SyterKit include: +Building SyterKit is a straightforward process that only requires setting up the environment for compilation on GNU/Linux, Windows or macOS(untested). The software packages required by SyterKit include: -- `gcc-arm-none-eabi` +- `gcc-arm-none-eabi` (`gcc-linaro-arm-eabi` works as well) - `CMake` +- `GNU Make` +#### Prepare Building Environment on GNU/Linux For commonly used Ubuntu systems, they can be installed using the following command: ```shell @@ -36,20 +38,44 @@ sudo apt-get update sudo apt-get install gcc-arm-none-eabi cmake build-essential -y ``` -Then create a folder to store the compiled output files and navigate to it: +#### Prepare Building Environment on Windows +On Windows, the packages are required to be installed by hand: +- [gcc-arm-eabi](https://releases.linaro.org/components/toolchain/binaries) +- [CMake](https://cmake.org/download/) +- [GNU Make](https://gnuwin32.sourceforge.net/packages/make.htm) + +*Note: it's a good idea to add the bin directories of above into `PATH` variable to avoid trouble.* + +#### Start building +Create a folder to store the compiled output files and navigate to it: ```shell mkdir build cd build ``` -Finally, run the following commands to compile SyterKit: +Run the following command to configure CMake cache: + +```shell +cmake .. -DCMAKE_BOARD_FILE="tinyvision.cmake" +``` + +Where `tinyvision` is the target board you want to build SyterKit for. Remove this parameter to see available boards. +*If you are using Windows, you may need to add parameter `-G 'Unix Makefiles'`, like* + +```shell +cmake .. -DCMAKE_BOARD_FILE="tinyvision.cmake" -G 'Unix Makefiles' +``` + +*This parameter may be not required, add it when CMake is trying to generate a Visual Studio project or something else.* +Run the following commands to build SyterKit ```shell -cmake .. -make +cd build +cmake --build . # You can add "-j" to enable multi-thread compilation ``` + The compiled executable files will be located in `build/app`. ![image-20231206212123866](assets/post/README/image-20231206212123866.png) @@ -59,6 +85,8 @@ The SyterKit project will compile two versions: firmware ending with `.elf` is f - For SD Card, You need to flash the `xxx_card.bin` - For SPI NAND/SPI NOR, You need to flash the `xxx_spi.bin` +To boot from USB or flash the boot image into SPI flash chips, you need to install the [XFEL](https://xboot.org/xfel) tool. + ### Creating TF Card Boot Firmware After build the firmware, you can flash it into the TF card. For the V851s platform, you can write it to either an 8K offset or a 128K offset. Generally, if the TF card uses MBR format, write it with an 8K offset. If it uses GPT format, write it with a 128K offset. Assuming `/dev/sdb` is the target TF card, you can use the following command to write it with an 8K offset: @@ -119,6 +147,17 @@ Use the xfel tool to flash the created firmware into SPI NOR: xfel spinor write 0x0 spi.img ``` +### Booting from USB +Allwinner SoCs support `FEL` mode, which enables them to boot from USB, which is a convenient way to test SyterKit. Make sure you have installed XFEL tool,then you can load the fel image into the chip's memory and boot it: + +For example, to boot the `hello_world` firmware, you can use the following + +```shell +xfel write 0x28000 syter_boot_elf.bin # load the firmware into memory, 0x28000 is the beginning address of the SRAM of Allwinner V85x. + +xfel exec 0x28000 # boot the firmware +``` +Then you can see the output of the firmware from UART0. # SyterKit @@ -144,11 +183,13 @@ SyterKit 是一个纯裸机框架,用于 TinyVision 或者其他 v851se/v851s/ ### 从零构建 SyterKit -构建 SyterKit 非常简单,只需要在 Linux 操作系统中安装配置环境即可编译。SyterKit 需要的软件包有: +构建 SyterKit 非常简单,只需要在 GNU/Linux, Windows或macOS(未测试) 操作系统中安装配置环境即可编译。SyterKit 需要的软件包有: - `gcc-arm-none-eabi` - `CMake` +- `GNU Make` +#### 在 GNU/Linux 上准备构建环境 对于常用的 Ubuntu 系统,可以通过如下命令安装 ```shell @@ -156,18 +197,44 @@ sudo apt-get update sudo apt-get install gcc-arm-none-eabi cmake build-essential -y ``` -然后新建一个文件夹存放编译的输出文件,并且进入这个文件夹 +#### 在 Windows 上准备构建环境 +在 Windows 上,需要手动安装软件包: +- [gcc-arm-eabi](https://releases.linaro.org/components/toolchain/binaries) +- [CMake](https://cmake.org/download/) +- [GNU Make](https://gnuwin32.sourceforge.net/packages/make.htm) + +*注意:建议将上述软件包的 bin 目录添加到 `PATH` 环境变量中,以免出现麻烦。* + +#### 开始构建 + +新建一个文件夹存放编译的输出文件,并且进入这个文件夹 ```shell mkdir build cd build ``` -然后运行命令编译 SyterKit +运行以下命令配置 CMake 缓存 + +```shell +cmake .. -DCMAKE_BOARD_FILE="tinyvision.cmake" +``` +其中`tinyvision`是要构建SyterKit的目标开发板,可以通过去掉这个参数来查看可用的开发板列表。 + +*如果你使用的是 Windows,你可能需要添加`-G 'Unix Makefiles'`参数,例如:* + +```shell +cmake .. -DCMAKE_BOARD_FILE="tinyvision.cmake" -G 'Unix Makefiles' +``` + +*这个参数可能不是必须的,当 CMake 尝试生成 Visual Studio 项目或其他项目时添加它。* + + +运行命令构建 SyterKit ```shell -cmake .. -make +cd build +cmake --build . # 可以添加 "-j" 开启多线程编译 ``` 编译后的可执行文件位于 `build/app` 中 @@ -179,6 +246,7 @@ make - 对于 SD 卡,你需要刷写 `xxx_card.bin` 文件。 - 对于 SPI NAND/SPI NOR,你需要刷写 `xxx_spi.bin` 文件。 +要通过 USB 引导或者刷写 SPI Flash 的固件,你需要安装 [XFEL](https://xboot.org/xfel) 工具。 ### 制作 TF 卡启动固件 @@ -239,3 +307,15 @@ dd if=zImage of=spi.img bs=2k seek=256 # Kernel on page 256 ```shell xfel spinor write 0x0 spi.img ``` + +### 通过 USB 引导 + +Allwinner SoC 支持 `FEL` 模式,可以通过 USB 引导,这是一个方便的测试 SyterKit 的方式。确保你已经安装了 XFEL 工具,然后可以将 fel 镜像加载到芯片的内存中并启动它。 + +例如,要引导 `hello_world` 固件,可以使用以下命令 + +```shell +xfel write 0x28000 syter_boot_elf.bin # 把固件加载到内存中,0x28000 是 Allwinner V85x 的 SRAM 的起始地址。 + +xfel exec 0x28000 # 启动固件 +``` diff --git a/include/common.h b/include/common.h index 3f1a39e9..715d46c4 100644 --- a/include/common.h +++ b/include/common.h @@ -3,6 +3,10 @@ #ifndef __COMMON_H__ #define __COMMON_H__ +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + #include #include #include @@ -40,4 +44,8 @@ int raise(int signum); void show_banner(void); +#ifdef __cplusplus +} +#endif // __cplusplus + #endif// __COMMON_H__ \ No newline at end of file diff --git a/include/ctype.h b/include/ctype.h index c8e1b167..28bf3fc0 100644 --- a/include/ctype.h +++ b/include/ctype.h @@ -2,7 +2,9 @@ #ifndef __CTYPE_H__ #define __CTYPE_H__ - +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus int isalnum(int c); int isalpha(int c); @@ -35,4 +37,8 @@ int tolower(int c); int toupper(int c); +#ifdef __cplusplus +} +#endif // __cplusplus + #endif /* __CTYPE_H__ */ \ No newline at end of file diff --git a/include/drivers/pmu/axp.h b/include/drivers/pmu/axp.h index cc7d71fa..fc407af8 100644 --- a/include/drivers/pmu/axp.h +++ b/include/drivers/pmu/axp.h @@ -10,6 +10,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + typedef struct _axp_step_info { uint32_t step_min_vol; uint32_t step_max_vol; @@ -37,4 +41,8 @@ int pmu_axp1530_set_vol(sunxi_i2c_t *i2c_dev, char *name, int set_vol, int onoff void pmu_axp1530_dump(sunxi_i2c_t *i2c_dev); +#ifdef __cplusplus +} +#endif // __cplusplus + #endif // __G_AXP_H__ \ No newline at end of file diff --git a/include/drivers/sun50iw9/sys-clk.h b/include/drivers/sun50iw9/sys-clk.h index b63faa57..d8333559 100644 --- a/include/drivers/sun50iw9/sys-clk.h +++ b/include/drivers/sun50iw9/sys-clk.h @@ -3,10 +3,18 @@ #include "reg/reg-ccu.h" +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + void sunxi_clk_init(void); void sunxi_clk_reset(void); void sunxi_clk_dump(void); +#ifdef __cplusplus +} +#endif // __cplusplus + #endif// __SUN50IW9_CLK_H__ \ No newline at end of file diff --git a/include/drivers/sun50iw9/sys-dram.h b/include/drivers/sun50iw9/sys-dram.h index 46acbb5b..ef461fd7 100644 --- a/include/drivers/sun50iw9/sys-dram.h +++ b/include/drivers/sun50iw9/sys-dram.h @@ -12,6 +12,14 @@ #define SDRAM_BASE (0x40000000) +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + uint64_t sunxi_dram_init(); +#ifdef __cplusplus +} +#endif // __cplusplus + #endif // __SUN50IW9_SYS_DRAM_H__ diff --git a/include/drivers/sun50iw9/sys-sid.h b/include/drivers/sun50iw9/sys-sid.h index 875f0358..ab8d41b9 100644 --- a/include/drivers/sun50iw9/sys-sid.h +++ b/include/drivers/sun50iw9/sys-sid.h @@ -14,6 +14,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + static const struct sid_section_t { char *name; uint32_t offset; @@ -60,4 +64,8 @@ void syter_efuse_write(uint32_t offset, uint32_t value); void syter_efuse_dump(void); +#ifdef __cplusplus +} +#endif // __cplusplus + #endif// __SUN50IW9_SYS_SID_H__ \ No newline at end of file diff --git a/include/drivers/sun8iw20/sys-clk.h b/include/drivers/sun8iw20/sys-clk.h index 373a904c..650fcfff 100644 --- a/include/drivers/sun8iw20/sys-clk.h +++ b/include/drivers/sun8iw20/sys-clk.h @@ -3,10 +3,18 @@ #include "reg/reg-ccu.h" +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + void sunxi_clk_init(void); void sunxi_clk_reset(void); void sunxi_clk_dump(void); +#ifdef __cplusplus +} +#endif // __cplusplus + #endif// __SUN8IW20_CLK_H__ \ No newline at end of file diff --git a/include/drivers/sun8iw20/sys-dram.h b/include/drivers/sun8iw20/sys-dram.h index 60e34297..9857984f 100644 --- a/include/drivers/sun8iw20/sys-dram.h +++ b/include/drivers/sun8iw20/sys-dram.h @@ -14,6 +14,10 @@ #define SDRAM_BASE (0x40000000) +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + enum sunxi_dram_type { SUNXI_DRAM_TYPE_DDR2 = 2, SUNXI_DRAM_TYPE_DDR3 = 3, @@ -58,4 +62,8 @@ int init_DRAM(int type, dram_para_t *para); uint64_t sunxi_dram_init(dram_para_t *para); +#ifdef __cplusplus +} +#endif // __cplusplus + #endif // __SUN8IW20_SYS_DRAM_H__ diff --git a/include/drivers/sun8iw20/sys-rproc.h b/include/drivers/sun8iw20/sys-rproc.h index 725a5f8f..ed70c498 100644 --- a/include/drivers/sun8iw20/sys-rproc.h +++ b/include/drivers/sun8iw20/sys-rproc.h @@ -5,8 +5,16 @@ #include "reg/reg-rproc.h" +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + void sunxi_c906_clock_init(uint32_t addr); void sunxi_c906_clock_reset(void); +#ifdef __cplusplus +} +#endif // __cplusplus + #endif// __SUN8IW20_SYS_RPROC_H__ \ No newline at end of file diff --git a/include/drivers/sun8iw20/sys-sid.h b/include/drivers/sun8iw20/sys-sid.h index abfffa84..efd0dc03 100644 --- a/include/drivers/sun8iw20/sys-sid.h +++ b/include/drivers/sun8iw20/sys-sid.h @@ -14,6 +14,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + static const struct sid_section_t { char *name; uint32_t offset; @@ -54,4 +58,8 @@ void syter_efuse_write(uint32_t offset, uint32_t value); void syter_efuse_dump(void); +#ifdef __cplusplus +} +#endif // __cplusplus + #endif// __SUN8IW20_SYS_SID_H__ \ No newline at end of file diff --git a/include/drivers/sun8iw21/sys-clk.h b/include/drivers/sun8iw21/sys-clk.h index f7fbccbb..147dadde 100644 --- a/include/drivers/sun8iw21/sys-clk.h +++ b/include/drivers/sun8iw21/sys-clk.h @@ -3,10 +3,18 @@ #include "reg/reg-ccu.h" +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + void sunxi_clk_init(void); void sunxi_clk_reset(void); void sunxi_clk_dump(void); +#ifdef __cplusplus +} +#endif // __cplusplus + #endif// __SUN8IW21_CLK_H__ \ No newline at end of file diff --git a/include/drivers/sun8iw21/sys-dram.h b/include/drivers/sun8iw21/sys-dram.h index 1ec41d0d..fa5f3172 100644 --- a/include/drivers/sun8iw21/sys-dram.h +++ b/include/drivers/sun8iw21/sys-dram.h @@ -14,6 +14,10 @@ #define SDRAM_BASE (0x40000000) +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + enum sunxi_dram_type { SUNXI_DRAM_TYPE_DDR2 = 2, SUNXI_DRAM_TYPE_DDR3 = 3, @@ -58,4 +62,8 @@ int init_DRAM(int type, dram_para_t *para); uint64_t sunxi_dram_init(dram_para_t *para); +#ifdef __cplusplus +} +#endif // __cplusplus + #endif // __SUN8IW21_SYS_DRAM_H__ diff --git a/include/drivers/sun8iw21/sys-rproc.h b/include/drivers/sun8iw21/sys-rproc.h index d3ef8122..f33ae1f5 100644 --- a/include/drivers/sun8iw21/sys-rproc.h +++ b/include/drivers/sun8iw21/sys-rproc.h @@ -5,8 +5,16 @@ #include "reg/reg-rproc.h" +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + void sunxi_e907_clock_init(uint32_t addr); void sunxi_e907_clock_reset(void); +#ifdef __cplusplus +} +#endif // __cplusplus + #endif// __SUN8IW21_SYS_RPROC_H__ \ No newline at end of file diff --git a/include/drivers/sun8iw21/sys-sid.h b/include/drivers/sun8iw21/sys-sid.h index 0a5daf44..6b179d37 100644 --- a/include/drivers/sun8iw21/sys-sid.h +++ b/include/drivers/sun8iw21/sys-sid.h @@ -14,6 +14,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + static const struct sid_section_t { char *name; uint32_t offset; @@ -45,4 +49,8 @@ void syter_efuse_write(uint32_t offset, uint32_t value); void syter_efuse_dump(void); +#ifdef __cplusplus +} +#endif // __cplusplus + #endif// __SUN8IW21_SYS_SID_H__ \ No newline at end of file diff --git a/include/drivers/sys-dma.h b/include/drivers/sys-dma.h index f10c1c9e..ac649391 100644 --- a/include/drivers/sys-dma.h +++ b/include/drivers/sys-dma.h @@ -15,6 +15,10 @@ #include "reg-dma.h" +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + typedef struct { uint32_t volatile config; uint32_t volatile source_addr; @@ -115,4 +119,8 @@ int dma_querystatus(uint32_t hdma); int dma_test(uint32_t *src_addr, uint32_t *dst_addr); +#ifdef __cplusplus +} +#endif // __cplusplus + #endif /* _SUNXI_DMA_H */ diff --git a/include/drivers/sys-gpio.h b/include/drivers/sys-gpio.h index c571976c..d2dc78c7 100644 --- a/include/drivers/sys-gpio.h +++ b/include/drivers/sys-gpio.h @@ -11,7 +11,9 @@ #include #include -#include "log.h" +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus enum { GPIO_INPUT = 0, @@ -115,4 +117,8 @@ extern int sunxi_gpio_read(gpio_t pin); extern void sunxi_gpio_set_pull(gpio_t pin, enum gpio_pull_t pull); +#ifdef __cplusplus +} +#endif // __cplusplus + #endif \ No newline at end of file diff --git a/include/drivers/sys-i2c.h b/include/drivers/sys-i2c.h index 50c48a01..89ab465c 100644 --- a/include/drivers/sys-i2c.h +++ b/include/drivers/sys-i2c.h @@ -10,6 +10,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + typedef struct { uint32_t base; uint8_t id; @@ -109,4 +113,8 @@ int sunxi_i2c_read(sunxi_i2c_t *i2c_dev, uint8_t addr, uint32_t reg, uint8_t *da * F8h No relevant status information or no interrupt *-----------------------------------------------------------------------------*/ +#ifdef __cplusplus +} +#endif // __cplusplus + #endif// __SYS_I2C_H__ \ No newline at end of file diff --git a/include/drivers/sys-rtc.h b/include/drivers/sys-rtc.h index e47ec302..2795bafb 100644 --- a/include/drivers/sys-rtc.h +++ b/include/drivers/sys-rtc.h @@ -16,6 +16,10 @@ #define RTC_FEL_INDEX 2 #define RTC_BOOT_INDEX 6 +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + /* Write data to the RTC register at the specified index */ void rtc_write_data(int index, uint32_t val); @@ -40,4 +44,8 @@ int rtc_set_bootmode_flag(uint8_t flag); /* Get the bootmode flag from the RTC register */ int rtc_get_bootmode_flag(void); +#ifdef __cplusplus +} +#endif // __cplusplus + #endif// __SYS_RTC_H__ \ No newline at end of file diff --git a/include/drivers/sys-sdcard.h b/include/drivers/sys-sdcard.h index 99a279bb..cc600f41 100644 --- a/include/drivers/sys-sdcard.h +++ b/include/drivers/sys-sdcard.h @@ -14,6 +14,10 @@ #include "log.h" +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + enum { /* Class 1 */ MMC_GO_IDLE_STATE = 0, @@ -195,4 +199,8 @@ int sdmmc_init(sdmmc_pdata_t *data, sdhci_t *hci); uint64_t sdmmc_blk_read(sdmmc_pdata_t *data, uint8_t *buf, uint64_t blkno, uint64_t blkcnt); +#ifdef __cplusplus +} +#endif // __cplusplus + #endif /* __SDCARD_H__ */ diff --git a/include/drivers/sys-sdhci.h b/include/drivers/sys-sdhci.h index f849446c..f7f5bfb5 100644 --- a/include/drivers/sys-sdhci.h +++ b/include/drivers/sys-sdhci.h @@ -15,6 +15,10 @@ #include "log.h" +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + typedef enum { MMC_CLK_400K = 0, MMC_CLK_25M, @@ -95,4 +99,8 @@ bool sdhci_set_clock(sdhci_t *hci, smhc_clk_t hz); bool sdhci_transfer(sdhci_t *hci, sdhci_cmd_t *cmd, sdhci_data_t *dat); int sunxi_sdhci_init(sdhci_t *sdhci); +#ifdef __cplusplus +} +#endif // __cplusplus + #endif /* __SDHCI_H__ */ diff --git a/include/drivers/sys-spi-nand.h b/include/drivers/sys-spi-nand.h index 0737f613..c5df0f04 100644 --- a/include/drivers/sys-spi-nand.h +++ b/include/drivers/sys-spi-nand.h @@ -16,6 +16,10 @@ #include "log.h" +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + typedef struct { uint8_t mfr; uint16_t dev; @@ -53,4 +57,8 @@ int spi_nand_detect(sunxi_spi_t *spi); */ uint32_t spi_nand_read(sunxi_spi_t *spi, uint8_t *buf, uint32_t addr,uint32_t rxlen); +#ifdef __cplusplus +} +#endif // __cplusplus + #endif // __SYS_SPI_NAND_H__ \ No newline at end of file diff --git a/include/drivers/sys-uart.h b/include/drivers/sys-uart.h index a1b27d6b..c36490e4 100644 --- a/include/drivers/sys-uart.h +++ b/include/drivers/sys-uart.h @@ -4,6 +4,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + typedef struct { uint32_t base; uint8_t id; @@ -19,4 +23,8 @@ int sunxi_serial_tstc(void *arg); char sunxi_serial_getc(void *arg); +#ifdef __cplusplus +} +#endif // __cplusplus + #endif // __SYS_UART_H__ \ No newline at end of file diff --git a/include/drivers/sys-wdt.h b/include/drivers/sys-wdt.h index ab4a0ef9..d4ff4302 100644 --- a/include/drivers/sys-wdt.h +++ b/include/drivers/sys-wdt.h @@ -12,6 +12,14 @@ #include "log.h" +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + void sys_reset(); +#ifdef __cplusplus +} +#endif // __cplusplus + #endif// __SYS_WDT_H__ \ No newline at end of file diff --git a/include/fdt_wrapper.h b/include/fdt_wrapper.h index ca6d2b89..9439a817 100644 --- a/include/fdt_wrapper.h +++ b/include/fdt_wrapper.h @@ -1,6 +1,10 @@ #ifndef __FDT_WRAPPER_H__ #define __FDT_WRAPPER_H__ +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + #ifndef __packed #define __packed __attribute__((__packed__)) #endif @@ -19,4 +23,8 @@ int fdt_parse_prop(char const **newval, int count, char *data, int *len); int fdt_increase_size(void *fdt, int add_len); +#ifdef __cplusplus +} +#endif // __cplusplus + #endif //__FDT_WRAPPER_H__ \ No newline at end of file diff --git a/include/log.h b/include/log.h index c0274bf0..2ed2114a 100644 --- a/include/log.h +++ b/include/log.h @@ -14,6 +14,10 @@ #include "xformat.h" +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + enum { LOG_LEVEL_TRACE = 0, LOG_LEVEL_DEBUG = 1, @@ -33,4 +37,8 @@ void printk(int level, const char *fmt, ...); void uart_printf(const char *fmt, ...); +#ifdef __cplusplus +} +#endif // __cplusplus + #endif diff --git a/include/smalloc.h b/include/smalloc.h index 4bde477a..e53b6b40 100644 --- a/include/smalloc.h +++ b/include/smalloc.h @@ -6,6 +6,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + struct alloc_struct_t { phys_addr_t address; uint32_t size; @@ -23,4 +27,8 @@ void *srealloc(void *p, uint32_t num_bytes); void sfree(void *p); +#ifdef __cplusplus +} +#endif // __cplusplus + #endif// __SMALLOC_H__ \ No newline at end of file diff --git a/include/sstdlib.h b/include/sstdlib.h index 0e4bfcfa..598089eb 100644 --- a/include/sstdlib.h +++ b/include/sstdlib.h @@ -5,6 +5,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + extern unsigned long simple_strtoul(const char *cp, char **endp, unsigned int base); extern unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int base); @@ -37,5 +41,8 @@ extern long long simple_atoll(const char *nptr); extern int simple_abs(int n); +#ifdef __cplusplus +} +#endif // __cplusplus #endif// __STDLIB_H__ \ No newline at end of file diff --git a/include/string.h b/include/string.h index d195a2cb..458da961 100644 --- a/include/string.h +++ b/include/string.h @@ -5,6 +5,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + extern void *memcpy(void *dst, const void *src, int cnt); extern void *memset(void *dst, int val, int cnt); @@ -35,4 +39,8 @@ extern void *memchr(void *ptr, int value, unsigned int num); extern void *memmove(void *dest, const void *src, unsigned int count); +#ifdef __cplusplus +} +#endif // __cplusplus + #endif /* #ifndef __STRING_H__ */ diff --git a/include/uart.h b/include/uart.h index 60ce45d7..78e185e5 100644 --- a/include/uart.h +++ b/include/uart.h @@ -3,6 +3,10 @@ #ifndef __CLI_UART_H__ #define __CLI_UART_H__ +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + int uart_putchar(int c); int uart_puts(const char *s); @@ -17,4 +21,8 @@ int tstc(); extern int puts(const char *); +#ifdef __cplusplus +} +#endif // __cplusplus + #endif//__CLI_UART_H__ \ No newline at end of file diff --git a/include/xformat.h b/include/xformat.h index 3611afb9..b69ffe50 100644 --- a/include/xformat.h +++ b/include/xformat.h @@ -40,9 +40,17 @@ #define XCFG_FORMAT_LONGLONG 0 #endif +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + unsigned xvformat(void (*outchar)(void *arg, char), void *arg, const char *fmt, va_list args); unsigned xformat(void (*outchar)(void *arg, char), void *arg, const char *fmt, ...); +#ifdef __cplusplus +} +#endif // __cplusplus + #endif diff --git a/scripts/genimage.sh b/scripts/genimage.sh old mode 100755 new mode 100644 diff --git a/tools/bin2array.exe b/tools/bin2array.exe new file mode 100644 index 00000000..b2d85b4c Binary files /dev/null and b/tools/bin2array.exe differ diff --git a/tools/mksunxi.exe b/tools/mksunxi.exe new file mode 100644 index 00000000..cf85c077 Binary files /dev/null and b/tools/mksunxi.exe differ