Skip to content

Commit

Permalink
Work on multi-board build
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoskal committed Nov 21, 2016
1 parent 1120af8 commit 78089e3
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 11 deletions.
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
BOARD=zero
-include Makefile.user
CC=arm-none-eabi-gcc
COMMON_FLAGS = -mthumb -mcpu=cortex-m0plus -Os -g
CDEFINES = -D__SAMD21G18A__
WFLAGS = \
-Wall -Wstrict-prototypes \
-Werror-implicit-function-declaration -Wpointer-arith -std=gnu99 \
Expand All @@ -16,17 +17,18 @@ CFLAGS = $(COMMON_FLAGS) \
-x c -c -pipe -nostdlib \
--param max-inline-insns-single=500 \
-fno-strict-aliasing -fdata-sections -ffunction-sections -mlong-calls \
$(WFLAGS) $(CDEFINES)
$(WFLAGS)

LDFLAGS= $(COMMON_FLAGS) \
-Wall -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common \
-Wl,--warn-section-align -Wl,--warn-unresolved-symbols \
-save-temps -T./asf/sam0/utils/linker_scripts/samd21/gcc/samd21j18a_flash.ld \
--specs=nano.specs --specs=nosys.specs
BUILD_PATH=build
BUILD_PATH=build/$(BOARD)
INCLUDES = -I./inc -I./inc/preprocessor
INCLUDES += -I./asf/sam0/utils/cmsis/samd21/include -I./asf/thirdparty/CMSIS/Include -I./asf/sam0/utils/cmsis/samd21/source
INCLUDES += -I./asf/common -I./asf/common/utils -I./asf/sam0/utils/header_files -I./asf/sam0/utils -I./asf/common/utils/interrupt
INCLUDES += -I./boards/$(BOARD)
SOURCES = $(wildcard src/*.c)
OBJECTS = $(patsubst src/%.c,$(BUILD_PATH)/%.o,$(SOURCES))

Expand Down
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* [x] extend magic with "UF2\n" string
* [x] align data in block to 32 bytes (for hex viewer)
* [x] show board serial number and name in info file
* [ ] organize board configs in directories
* [x] organize board configs in directories
* [ ] use BOOTPROT bits
* [x] if `!USE_CDC && !USE_UART` - don't compile monitor
* [x] if `!USE_CDC` don't compile the CDC code (not only exclude descriptors)
Expand Down
13 changes: 13 additions & 0 deletions boards/zero/board_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#ifndef BOARD_CONFIG_H
#define BOARD_CONFIG_H

#define __SAMD21G18A__ 1

#define VENDOR_NAME "Arduino"
#define PRODUCT_NAME "Zero"
#define VOLUME_LABEL "ARDUINO-M0"

#define USB_VID 0x2341
#define USB_PID 0x024D

#endif
8 changes: 4 additions & 4 deletions inc/uf2.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef UF2_H
#define UF2_H 1

#include "board_config.h"

#include "samd21.h"
#include "uf2format.h"
#include "main.h"
Expand All @@ -15,12 +17,10 @@
#undef DISABLE
#undef ENABLE


// needs to be more than ~4200 (to force FAT16)
#define NUM_FAT_BLOCKS 4200
#define VENDOR_NAME "ACME Corp."
#define PRODUCT_NAME "UF2 Bootloader"
#define NUM_FAT_BLOCKS 8000
#define SERIAL_NUMBER "F23456789ABC"
#define VOLUME_LABEL "UF2-SAMD"

// Logging to help debugging
#define USE_LOGS 1
Expand Down
1 change: 1 addition & 0 deletions src/interrupt_sam_nvic.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* ----------------------------------------------------------------------------
*/

#include "board_config.h"
#include "interrupt_sam_nvic.h"

#if !defined(__DOXYGEN__)
Expand Down
1 change: 1 addition & 0 deletions src/startup_samd21.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
*
*/

#include "board_config.h"
#include "samd21.h"

/* Initialize segments */
Expand Down
1 change: 1 addition & 0 deletions src/uart_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* ----------------------------------------------------------------------------
*/

#include "board_config.h"
#include "uart_driver.h"

bool uart_drv_error_flag = false;
Expand Down
4 changes: 1 addition & 3 deletions src/usart_sam_ba.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@
* ----------------------------------------------------------------------------
*/

#include "usart_sam_ba.h"
#include "compiler.h"
#include "main.h"
#include "uf2.h"
#include "uart_driver.h"

/* Variable to let the main task select the appropriate communication interface
Expand Down

0 comments on commit 78089e3

Please sign in to comment.