Skip to content

Commit 492fae4

Browse files
committed
Initial Example Project with Readme.
0 parents  commit 492fae4

11 files changed

+170
-0
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "bitthunder"]
2+
path = bitthunder
3+
url = git://github.com/jameswalmsley/bitthunder.git

Kconfig

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
comment "Example Project Configuration"
2+
3+
# Add as many dependencies as this BSP requires. I.e. MUST haves for this board.
4+
# E.g. select SHELL etc.
5+
6+
config PROJECT_DEPENDENCIES
7+
bool
8+
default y
9+
select SHELL

Makefile

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#
2+
# Example Makefile for a BitThunder Project.
3+
#
4+
5+
# Get a clean make.
6+
MAKEFLAGS += --no-print-directory
7+
8+
# Set the APP_DIR path (i.e. the current directory).
9+
APP_DIR="$(shell pwd)/"
10+
11+
# Ensure a .config file has been created and copied to the bitthunder root.
12+
# APP_DIR is passed to the sub-make, and APP_CONFIG is set (allowing use of application config).
13+
all: .config
14+
@cp .config bitthunder/.config
15+
@$(MAKE) -C bitthunder APP_DIR=$(APP_DIR) APP_CONFIG=y
16+
17+
# Proxy command to invoke the menuconfig correctly etc.
18+
# APP_BSP_CONFIG allows a separate BSP Kconfig to be used, and APP_BSP_DIR is the path to it.
19+
menuconfig:
20+
-@cp -f .config bitthunder/.config
21+
@$(MAKE) -C bitthunder APP_DIR=$(APP_DIR) APP_CONFIG=y menuconfig APP_BSP_CONFIG=y APP_BSP_DIR=../bsp
22+
@cp bitthunder/.config .config
23+
24+
# Call make with menuconfig to produce a valid configuration file.
25+
.config:
26+
@$(MAKE) menuconfig APP_DIR=$(APP_DIR)
27+
28+
# Proxy command for cleaning.
29+
clean:
30+
@$(MAKE) -C bitthunder APP_DIR=$(APP_DIR) APP_CONFIG=y clean

README.md

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
This is an example BitThunder project.
2+
3+
To build follow the steps below:
4+
5+
# 1. Create a valid configuration
6+
7+
make menuconfig
8+
9+
## Compiler
10+
11+
Be sure to set the compiler location under Build System -> Toolchain Prefix
12+
e.g. if your compiler is located at:
13+
14+
/opt/codesourcery/bin
15+
16+
Then your prefix is /opt/codesourcery/bin/arm-none-eabi- or something similar.
17+
18+
## Select Architecture and CPU
19+
Just the relevent architecture under the System Architecture menu. E.g. for STM32 choose ARM
20+
and STM32 :)
21+
22+
## Linking / Memory Definitions
23+
24+
BitThunder generates a linker description file automatically, but it needs to know
25+
what memories are available on your device.
26+
27+
Under the System Architecture menu, configure the Linking (new versions call this Memory)
28+
parameters.
29+
30+
Currently BT supports 3 different kinds of memories. Simply enable at least one of them,
31+
and define the start address and length in HEX. (One must be Read/Writable, e.g. at least an SRAM).
32+
33+
You can also request different sections to placed in different memories.
34+
For micro-controllers you will usually have a FLASH and SRAM. Enable both, and ensure that
35+
INIT and TEXT reside in FLASH, where Data and BSS reside in SRAM.
36+
37+
Leave the initial stack sizes as default.
38+
39+
## Exit and Save the configuration
40+
41+
# 2. Compile your kernel.
42+
43+
make
44+
45+
This should compile a valid bitthunder kernel for your platform.
46+
Files are output in the bsp folder, e.g. example.elf and example.list ...

bitthunder

Submodule bitthunder added at 9865962

bsp/.config.mk

Whitespace-only changes.

bsp/Kconfig

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
comment "Example BSP options"
2+
3+
config BSP_DIR
4+
string
5+
default "../bsp/"
6+
7+
config BSP_NAME
8+
string
9+
default "Example"

bsp/Makefile

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#
2+
# BSP Makefile for Example project.
3+
#
4+
5+
BINARY_NAME=example
6+
BASE=$(shell pwd)/../bitthunder/
7+
BUILD_BASE=$(BASE)
8+
MODULE_NAME="example"
9+
10+
TARGETS=$(BINARY_NAME).img
11+
TARGET_DEPS=$(BINARY_NAME).elf
12+
13+
BUILD_DIR=$(shell pwd)/build/
14+
15+
include $(BASE).dbuild/dbuild.mk
16+
17+
tool:
18+
@echo $(BASE)
19+
@echo $(BT_CONFIG_SUBARCH)
20+
@echo $(BT_CONFIG_TOOLCHAIN)
21+
@echo $(TOOLCHAIN)
22+
23+
all: $(BINARY_NAME).elf $(BINARY_NAME).list $(BINARY_NAME).img $(BINARY_NAME).syms
24+
$(Q)$(SIZE) $(BINARY_NAME).elf
25+
26+
$(BINARY_NAME).img: $(BINARY_NAME).elf
27+
$(Q)$(PRETTY) IMAGE $(MODULE_NAME) $@
28+
$(Q)$(OBJCOPY) $(BINARY_NAME).elf -O binary $@
29+
30+
$(BINARY_NAME).list: $(BINARY_NAME).elf
31+
$(Q)$(PRETTY) LIST $(MODULE_NAME) $@
32+
$(Q)$(OBJDUMP) -D $(BINARY_NAME).elf > $@
33+
34+
$(BINARY_NAME).syms: $(BINARY_NAME).elf
35+
$(Q)$(PRETTY) SYMS $(MODULE_NAME) $@
36+
$(Q)$(OBJDUMP) -t $(BINARY_NAME).elf > $@
37+
38+
$(BINARY_NAME).elf: $(OBJECTS)
39+
$(Q)$(PRETTY) --dbuild "LD" $(MODULE_NAME) $@
40+
$(Q)$(CC) -o $@ -T $(LINKER_SCRIPT) -Wl,-Map=$(BINARY_NAME).map -Wl,--gc-sections $(OBJECTS) -nostdlib -lc -lgcc

bsp/objects.mk

Whitespace-only changes.

example.c

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <bitthunder.h>
2+
3+
int main(void) {
4+
5+
// This is a kernel thread with FULL priviliges.
6+
7+
// Use the BT_CreateThread() function to create other threads,
8+
9+
// Use the BT_CreateProcess() function to create a full-blown process.
10+
11+
// Use the GPIO API:
12+
13+
BT_GpioSetDirection(0, BT_GPIO_DIR_OUTPUT); // Set GPIO 0 as output.
14+
BT_GpioSet(0, BT_TRUE); // Set GPIO 0 high.
15+
16+
while(1);
17+
18+
return 0;
19+
}

objects.mk

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#
2+
# Add application objects to be build to the objs variable.
3+
# You may also use objs-y also and therfore config based objects:
4+
#
5+
# e.g. objs-$(BT_CONFIG_MY_CONFIG_VARIABLE) += $(APP)object.o
6+
#
7+
8+
objs += $(APP)example.o
9+
10+
#include $(APP_DIR)common/objects.mk
11+
12+
$(objs): MODULE_NAME="Example"
13+
$(objs): CFLAGS += -I $(APP_DIR)include

0 commit comments

Comments
 (0)