Skip to content

Commit 0c2cfe9

Browse files
committed
native64: Add Linux/x86_64 board
Adds a separate board for native64 instead of the `NATIVE_64BIT` workaround. The files in `boards/native64` are more or less dummy files and just include the `boards/native` logic (similar to `openlabs-kw41z-mini-256kib`). The main logic for native is in `makefiles/arch/native.inc.mk`, `cpu/native` and `boards/native`. The remaining changes concern the build system, and change native board checks to native CPU checks to cover both boards.
1 parent 22dbbf4 commit 0c2cfe9

28 files changed

+262
-218
lines changed

Makefile.include

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ include $(RIOTMAKE)/boards.inc.mk
204204
include $(RIOTMAKE)/dependencies_debug.inc.mk
205205

206206
# Use TOOLCHAIN environment variable to select the toolchain to use.
207-
ifeq ($(BOARD),native)
207+
ifneq (,$(filter native native64,$(BOARD)))
208208
ifeq ($(OS),Darwin)
209209
$(shell $(COLOR_ECHO) "$(COLOR_RED)"Buildin on macOS is not supported."\
210210
"We recommend vagrant for building:$(COLOR_RESET)"\

boards/native/Makefile.features

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
CPU = native
22

3-
# Put defined MCU peripherals here (in alphabetical order)
4-
FEATURES_PROVIDED += periph_rtc
5-
FEATURES_PROVIDED += periph_rtc_ms
6-
FEATURES_PROVIDED += periph_timer
7-
FEATURES_PROVIDED += periph_uart
8-
FEATURES_PROVIDED += periph_gpio
9-
FEATURES_PROVIDED += periph_pwm
10-
FEATURES_PROVIDED += periph_qdec
3+
FEATURES_PROVIDED += arch_32bit
4+
NATIVE_ARCH_BIT = 32
115

12-
# Various other features (if any)
13-
FEATURES_PROVIDED += ethernet
14-
FEATURES_PROVIDED += motor_driver
6+
include $(RIOTBOARD)/native/common_features.inc.mk

boards/native/Makefile.include

Lines changed: 0 additions & 177 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
1-
NATIVEINCLUDES += -DNATIVE_INCLUDES
21
NATIVEINCLUDES += -I$(RIOTBOARD)/native/include/
3-
NATIVEINCLUDES += -I$(RIOTBASE)/core/lib/include/
4-
NATIVEINCLUDES += -I$(RIOTBASE)/core/include/
5-
NATIVEINCLUDES += -I$(RIOTBASE)/drivers/include/
6-
7-
# Set "NATIVE_64BIT=1" to compile for x86_64
8-
NATIVE_64BIT ?= 0
9-
10-
ifeq ($(OS),Darwin)
11-
DEBUGGER ?= lldb
12-
else
13-
DEBUGGER ?= gdb
14-
endif
152

163
# only use pyterm wrapper if term target is requested
174
ifeq (,$(filter term,$(MAKECMDGOALS)))
@@ -48,93 +35,6 @@ else
4835
endif
4936
endif
5037

51-
export VALGRIND ?= valgrind
52-
export CGANNOTATE ?= cg_annotate
53-
export GPROF ?= gprof
54-
55-
# basic cflags:
56-
CFLAGS += -Wall -Wextra -pedantic $(CFLAGS_DBG) $(CFLAGS_OPT)
57-
CFLAGS += -U_FORTIFY_SOURCE
58-
CFLAGS_DBG ?= -g3
59-
60-
ifneq (,$(filter backtrace,$(USEMODULE)))
61-
$(warning module backtrace is used, do not omit frame pointers)
62-
CFLAGS_OPT ?= -Og -fno-omit-frame-pointer
63-
else
64-
CFLAGS_OPT ?= -Og
65-
endif
66-
67-
# default std set to gnu11 if not overwritten by user
68-
ifeq (,$(filter -std=%, $(CFLAGS)))
69-
CFLAGS += -std=gnu11
70-
endif
71-
72-
ifeq ($(OS_ARCH),x86_64)
73-
ifeq ($(NATIVE_64BIT), 1)
74-
CFLAGS += -m64
75-
else
76-
CFLAGS += -m32
77-
endif
78-
endif
79-
ifneq (,$(filter -DDEVELHELP,$(CFLAGS)))
80-
CFLAGS += -fstack-protector-all
81-
endif
82-
ifeq ($(OS),FreeBSD)
83-
ifeq ($(OS_ARCH),amd64)
84-
ifeq ($(NATIVE_64BIT), 1)
85-
CFLAGS += -m64
86-
else
87-
CFLAGS += -m32 -DCOMPAT_32BIT -B/usr/lib32
88-
endif
89-
endif
90-
endif
91-
ifeq ($(OS),Darwin)
92-
CFLAGS += -Wno-deprecated-declarations
93-
endif
94-
95-
# unwanted (CXXUWFLAGS) and extra (CXXEXFLAGS) flags for c++
96-
CXXUWFLAGS +=
97-
CXXEXFLAGS +=
98-
99-
ifeq ($(OS_ARCH),x86_64)
100-
ifeq ($(NATIVE_64BIT), 1)
101-
LINKFLAGS += -m64
102-
else
103-
LINKFLAGS += -m32
104-
endif
105-
endif
106-
ifeq ($(OS),FreeBSD)
107-
ifeq ($(OS_ARCH),amd64)
108-
ifeq ($(NATIVE_64BIT), 1)
109-
LINKFLAGS += -m64
110-
else
111-
LINKFLAGS += -m32 -DCOMPAT_32BIT -L/usr/lib32 -B/usr/lib32
112-
endif
113-
endif
114-
LINKFLAGS += -L $(BINDIR)
115-
else
116-
LINKFLAGS += -ldl
117-
endif
118-
119-
# XFA (cross file array) support
120-
LINKFLAGS += -T$(RIOTBASE)/cpu/native/ldscripts/xfa.ld
121-
122-
# fix this warning:
123-
# ```
124-
# /usr/bin/ld: examples/hello-world/bin/native/cpu/tramp.o: warning: relocation against `_native_saved_eip' in read-only section `.text'
125-
# /usr/bin/ld: warning: creating DT_TEXTREL in a PIE
126-
# ```
127-
LINKFLAGS += -no-pie
128-
129-
# clean up unused functions
130-
CFLAGS += -ffunction-sections -fdata-sections
131-
ifeq ($(OS),Darwin)
132-
LINKFLAGS += -Wl,-dead_strip
133-
else
134-
LINKFLAGS += -Wl,--gc-sections
135-
endif
136-
LINKFLAGS += -ffunction-sections
137-
13838
# set the tap interface for term/valgrind
13939
PORT ?= tap0
14040
TERMFLAGS += $(PROCARGS) $(PORT)
@@ -160,80 +60,3 @@ ifneq (,$(filter periph_can,$(FEATURES_USED)))
16060
PERIPH_CAN_FLAGS ?= --can $(VCAN_IFACE)
16161
TERMFLAGS += $(PERIPH_CAN_FLAGS)
16262
endif
163-
164-
165-
ASFLAGS =
166-
ifeq ($(shell basename $(DEBUGGER)),lldb)
167-
DEBUGGER_FLAGS = -- $(ELFFILE) $(TERMFLAGS)
168-
else
169-
DEBUGGER_FLAGS = -q --args $(ELFFILE) $(TERMFLAGS)
170-
endif
171-
term-valgrind: export VALGRIND_FLAGS ?= \
172-
--leak-check=full \
173-
--track-origins=yes \
174-
--fullpath-after=$(RIOTBASE)/ \
175-
--read-var-info=yes
176-
debug-valgrind-server: export VALGRIND_FLAGS ?= --vgdb=yes --vgdb-error=0 -v \
177-
--leak-check=full --track-origins=yes --fullpath-after=$(RIOTBASE) \
178-
--read-var-info=yes
179-
term-cachegrind: export CACHEGRIND_FLAGS += --tool=cachegrind
180-
term-gprof: TERMPROG = GMON_OUT_PREFIX=gmon.out $(ELFFILE)
181-
all-valgrind: CFLAGS += -DHAVE_VALGRIND_H
182-
all-valgrind: NATIVEINCLUDES += $(shell pkg-config valgrind --cflags)
183-
all-gprof: CFLAGS += -pg
184-
all-gprof: LINKFLAGS += -pg
185-
186-
CFLAGS_ASAN += -fsanitize=address -fno-omit-frame-pointer -DNATIVE_MEMORY
187-
LINKFLAGS_ASAN += -fsanitize=address -fno-omit-frame-pointer
188-
all-asan: CFLAGS += $(CFLAGS_ASAN)
189-
all-asan: LINKFLAGS += $(LINKFLAGS_ASAN)
190-
all-asan: export AFL_USE_ASAN=1
191-
192-
INCLUDES += $(NATIVEINCLUDES)
193-
194-
CFLAGS += -DDEBUG_ASSERT_VERBOSE
195-
196-
# workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52624
197-
ifneq ($(shell gcc --version | head -1 | grep -E ' (4.6|4.7)'),)
198-
CFLAGS += -DHAVE_NO_BUILTIN_BSWAP16
199-
endif
200-
201-
# clumsy way to enable building native on osx:
202-
BUILDOSXNATIVE = 0
203-
ifeq ($(CPU),native)
204-
ifeq ($(OS),Darwin)
205-
BUILDOSXNATIVE = 1
206-
endif
207-
endif
208-
209-
all: # do not override first target
210-
211-
all-gprof: all
212-
213-
all-asan: all
214-
215-
all-valgrind: all
216-
217-
all-cachegrind: all
218-
219-
term-valgrind:
220-
$(VALGRIND) $(VALGRIND_FLAGS) $(ELFFILE) $(PORT)
221-
222-
debug-valgrind-server:
223-
$(VALGRIND) $(VALGRIND_FLAGS) $(ELFFILE) $(PORT)
224-
225-
debug-valgrind:
226-
$(eval VALGRIND_PID ?= $(shell pgrep -n memcheck-x86-li -u $(USER) | cut -d" " -f1))
227-
$(eval DEBUGGER_FLAGS := -ex "target remote | vgdb --pid=$(VALGRIND_PID)" $(DEBUGGER_FLAGS))
228-
$(DEBUGGER) $(DEBUGGER_FLAGS)
229-
230-
term-cachegrind:
231-
$(VALGRIND) $(CACHEGRIND_FLAGS) $(ELFFILE) $(PORT)
232-
233-
term-gprof: term
234-
235-
eval-gprof:
236-
$(GPROF) $(ELFFILE) $(shell ls -rt gmon.out* | tail -1)
237-
238-
eval-cachegrind:
239-
$(CGANNOTATE) $(shell ls -rt cachegrind.out* | tail -1)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Put defined MCU peripherals here (in alphabetical order)
2+
FEATURES_PROVIDED += periph_rtc
3+
FEATURES_PROVIDED += periph_rtc_ms
4+
FEATURES_PROVIDED += periph_timer
5+
FEATURES_PROVIDED += periph_uart
6+
FEATURES_PROVIDED += periph_gpio
7+
FEATURES_PROVIDED += periph_pwm
8+
FEATURES_PROVIDED += periph_qdec
9+
10+
# Various other features (if any)
11+
FEATURES_PROVIDED += ethernet
12+
FEATURES_PROVIDED += motor_driver

boards/native/doc.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525

2626
# Required packages
2727

28-
The `native` version of RIOT will produce a 32 bit binary by default.
29-
To compile for x86_64 set the environment variable `NATIVE_64BIT=1`.
3028
On Debian/Ubuntu you can install the required libraries with
3129

3230
```

boards/native64/Kconfig

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright (c) 2020 HAW Hamburg
2+
#
3+
# This file is subject to the terms and conditions of the GNU Lesser
4+
# General Public License v2.1. See the file LICENSE in the top level
5+
# directory for more details.
6+
#
7+
8+
config BOARD
9+
default "native64" if BOARD_NATIVE64
10+
11+
config BOARD_NATIVE64
12+
bool
13+
default y
14+
select CPU_MODEL_NATIVE
15+
16+
# Put defined MCU peripherals here (in alphabetical order)
17+
select HAS_PERIPH_RTC
18+
select HAS_PERIPH_RTC_MS
19+
select HAS_PERIPH_TIMER
20+
select HAS_PERIPH_UART
21+
select HAS_PERIPH_GPIO
22+
select HAS_PERIPH_PWM
23+
select HAS_PERIPH_QDEC
24+
25+
# Various other features (if any)
26+
select HAS_ETHERNET
27+
select HAS_MOTOR_DRIVER
28+
select HAVE_SDL
29+
30+
rsource "../native/drivers/Kconfig"

boards/native64/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
DIRS = $(RIOTBOARD)/native
2+
3+
include $(RIOTBASE)/Makefile.base

boards/native64/Makefile.dep

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include $(RIOTBOARD)/native/Makefile.dep

boards/native64/Makefile.features

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CPU = native
2+
3+
FEATURES_PROVIDED += arch_64bit
4+
NATIVE_ARCH_BIT = 64
5+
6+
include $(RIOTBOARD)/native/common_features.inc.mk

boards/native64/Makefile.include

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include $(RIOTBOARD)/native/Makefile.include

0 commit comments

Comments
 (0)