File Structure

The whole SDK package is composed of device firmware, the folder design is described below.

1. Basic Concept

The basic concept of FW folder structure is modularize and stratification for all source code. FW code belonged to same feature will be put to one dedicated folder and easy to include/exclude it. Refer to basic FW architecture shown below, the listed items will have corresponding folders.

Here is the example folder design for Kneron SDK. The dark blue and bold fonts are mandatory folder name used in SDK. The normal words may vary in different SDK release or depends on your project.

├───firmware
│ ├───app
│ ├───build
│ │ ├───solution_companion
│ │ │ ├───main_scpu
│ │ │ │ └───include
│ │ │ ├───sn72096_9x9
│ │ │ │ └───scpu_keil
│ ├───include
│ ├───mdw
│ │ ├───console
│ │ ├───dfu
│ │ ├───errand
│ │ ├───flash
│ │ ├───include
│ │ ├───ipc
│ │ ├───memory
│ │ ├───model
│ │ ├───power
│ │ ├───spi_com
│ │ ├───ssp
│ │ ├───system
│ │ ├───tdc
│ │ ├───usbd_com
│ │ ├───usbh2
│ │ └───utilities
│ ├───platform
│ │ ├───board
│ │ │ └───board_sn72096_9x9
│ │ ├───dev
│ │ │ ├───eeprom
│ │ │ ├───include
│ │ │ ├───nand
│ │ │ │ ├───gigadevice
│ │ │ │ └───winbond
│ │ │ ├───nor
│ │ │ ├───wifi
│ │ │ │ ├───BufList
│ │ │ │ ├───ESP8266
│ │ │ │ │ ├───CMSIS_DV_Results
│ │ │ │ │ └───Config
│ │ ├───kl720
│ │ │ ├───common
│ │ │ ├───scpu
│ │ │ │ ├───drv
│ │ │ │ │ └───include
│ │ │ │ ├───rtos
│ │ │ │ │ ├───rtx
│ │ │ │ │ │ └───include
│ │ │ │ └───startup
│ ├───utils
│ │ ├───bin_gen
│ │ │ └───flash_bin
│ │ ├───dfu
│ │ │ └───src
│ │ ├───flash_programmer
│ │ │ ├───nand
│ │ │ └───nor
│ │ ├───JLink_programmer
│ │ │ ├───bin
│ │ │ ├───Devices
│ │ │ │ ├───Kneron
│ │ │ │ │ └───Winbond
│ │ └───spl_aes

2. Detailed explanation

└───firmware

firmware: Contains all device FW source/lib code, utilities, build environment

├───firmware
│ ├───app
│ ├───build
│ ├───include
│ ├───mdw
│ ├───platform
│ └───utils

Basically, the firmware source_code=app+mdw+platform(+include). We hope all firmware source code will be put under these 3 folders and will not be influenced by any projects, that is, it's a source code data base. All project related code will be put under build folder.

app: All application firmware code. Every module or C file have prefix kapp_.

build: Build environment. Include (Keil) project files, workspace, main.c, makefiles. C source files will be pulled in a project and then engineer generates a new project.

include: C header files for all source code

mdw: Middleware. It's kind of "service", "manager". We can put some useful and special purpose pure software feature here, such as file system, software timer, DFU function, memory management.

platform: It means a HW platform or a SoC for AI development. Platform consists of an SoC, a PCB, and some onboard devices(flash, eeprom...).

utils: some useful utilities, such as flash programming, calculate checksum...

├───firmware
│ ├───build
│ │ ├───example_xxx
│ │ ├───lib
│ │ ├───solution_xxx

There are two major components in build folder, example projects and solution projects. As the name implies, small app demo, simple peripheral drivers demo, or any features demonstration belong to example projects. The purpose is to show how to use our SDK. Solution projects is a solution for customer. It contains more features, or complex functions in a single project. Example projects will have example_ prefix and solution projects will have solution_ prefix. If you need to build a library and share with other projects, create lib projects in lib folder.

example_ : a prefix for example project. ex. example_i2c, example_tiny_yolo

solution_ : a prefix for solution project. ex. solution_kdp2, solution_door_lock

lib: Some source files need to be hidden or need to generate library. Put the library project here

├───firmware
│ ├───mdw
│ │ ├───console
│ │ ├───dfu
│ │ ├───errand
│ │ ├───flash
... ...

Collect independent modules to become middle ware here. It can be generic flash driver, firmware upgrade manager, file system...etc.

├───firmware
│ ├───platform
│ │ ├───board
│ │ ├───dev
│ │ │ ├───eeprom
│ │ │ ├───nand
│ │ │ ├───nor
│ │ │ └───wifi
│ │ ├───kl720
│ │ │ ├───common
│ │ │ ├───scpu
│ │ │ │ ├───drv
│ │ │ │ ├───rtos
│ │ │ │ └───startup

Platform = board + dev + ASIC.

board: PCB information, flash size, IO mapping,

dev: device drivers, such as flash driver, eeprom driver, wifi module driver, panel driver, sensor driver

kl720: contain all peripheral drivers, real time OS, startup assembly code, and FW init code.