Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .gdb_history
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ni
ni
ni
q
ni
ni
ni
ni
ni
ni
q
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"files.associations": {
"task.h": "c"
}
}
1 change: 1 addition & 0 deletions FreeRTOS-Kernel
Submodule FreeRTOS-Kernel added at 7225fb
62 changes: 62 additions & 0 deletions port/.gdb_history
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
ni
si
si
si
si
ni
c
break start
c
n
q
q
c
break xPortSysTickHandler
c
q
break xPortSysTickHandler
c
q
break xPortSysTickHandler
c
c
q
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
ni
ni
ni
ni
ni
ni
ni
break xPortSysTickHandler
c
break prvPortStartFirstTask
c
break default
n
n
q
18 changes: 18 additions & 0 deletions port/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef _CONFIG_H
#define __CONFIG_H__

#define configTICK_TYPE_WIDTH_IN_BITS TICK_TYPE_WIDTH_32_BITS
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 191 // 0xBF
#define configKERNEL_INTERRUPT_PRIORITY 255 // 0xFF

#define configMINIMAL_STACK_SIZE 0x100
#define configMAX_PRIORITIES 5
#define configUSE_PREEMPTION 1
#define configUSE_IDLE_HOOK 0
#define configUSE_TICK_HOOK 0
#define configTOTAL_HEAP_SIZE 0x1000
#define configCPU_CLOCK_HZ 80000000UL
#define configTICK_RATE_HZ 10
#define configASSERT(x) if((x)==0){taskDISABLE_INTERRUPTS(); for(;;);}

#endif
48 changes: 48 additions & 0 deletions port/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
PROJ = main
CPU ?= cortex-m3
BOARD ?= stm32vldiscovery

FREERTOS_PATH = ../FreeRTOS-Kernel



OBJ = boot.o \
start.o \
portFunctions.o \
$(FREERTOS_PATH)/tasks.o \
$(FREERTOS_PATH)/list.o \
$(FREERTOS_PATH)/portable/MemMang/heap_4.o \
$(FREERTOS_PATH)/portable/GCC/ARM_CM3/port.o \

INC = -I$(FREERTOS_PATH)/portable/GCC/ARM_CM3/ \
-I$(FREERTOS_PATH)/include/ \
-I. \

.PHONY: all
all: $(PROJ).elf

# Assemble .S file into .o
%.o: %.S
arm-none-eabi-as -mthumb -mcpu=$(CPU) -g -o $@ $<

%.o: %.c
arm-none-eabi-gcc $(INC) -mthumb -mcpu=$(CPU) -g -c $^ -o $@

# Link object into ELF
$(PROJ).elf: $(OBJ)
arm-none-eabi-ld -Tmap.ld $^ -o $@

# Disassemble
arm-none-eabi-objdump -D -S $@ > $@.lst
arm-none-eabi-readelf -a $@ > $@.debug

# QEMU launch
qemu:
qemu-system-arm -S -M $(BOARD) -cpu $(CPU) -nographic -kernel $(PROJ).elf -gdb tcp::1234

# GDB remote debug
gdb:
gdb-multiarch -q $(PROJ).elf -ex "target remote localhost:1234"

clean:
rm -rf *.o *.elf *.lst *.debug
59 changes: 59 additions & 0 deletions port/boot.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
.section .vectors
vector_table:
.word __stack
.word reset_handler
.word default
.word default
.word default
.word default
.word default
.word default
.word default
.word default
.word default
.word vPortSVCHandler
.word default
.word default
.word xPortPendSVHandler
.word xPortSysTickHandler
.zero 400

.section .text
.align 2
.thumb_func
.type default, %function
.type reset_handler, %function

reset_handler:
// Copy initialized data from FLASH to RAM
ldr r0, =_sidata // source: flash
ldr r1, =_sdata // destination: ram
ldr r2, =_edata // end of data

copy_data:
cmp r1, r2
bcs zero_bss // if r1 >= r2, jump to zero_bss
ldr r3, [r0]
str r3, [r1]
add r0, r0, #4
add r1, r1, #4
b copy_data

zero_bss:
ldr r0, =_sbss
ldr r1, =_ebss

zero_loop:
cmp r0, r1
bcs call_main
movs r2, #0
str r2, [r0]
add r0, r0, #4
b zero_loop

call_main:
bl start
b .

default:
b .
Binary file added port/boot.o
Binary file not shown.
Binary file added port/main.elf
Binary file not shown.
Loading