Skip to content

Commit f3a36e8

Browse files
committed
Initial commit.
0 parents  commit f3a36e8

File tree

30 files changed

+3820
-0
lines changed

30 files changed

+3820
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
archives/
2+
builds/
3+
src/
4+
tools/
5+
releases/

COPYING

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

NOTICE

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Open Firmware Dataset Builder (OFDB)
2+
3+
Copyright 2023-2024 Vincent Dary

README.md

Lines changed: 238 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
################################################################################
2+
#
3+
# Copyright 2023-2024 Vincent Dary
4+
#
5+
# This file is part of open-firmware-dataset-builder (OFDB).
6+
#
7+
# open-firmware-dataset-builder is free software: you can redistribute it and/or
8+
# modify it under the terms of the GNU General Public License as published by
9+
# the Free Software Foundation, either version 3 of the License, or (at your
10+
# option) any later version.
11+
#
12+
# open-firmware-dataset-builder is distributed in the hope that it will be
13+
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15+
# Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License along with
18+
# open-firmware-dataset-builder. If not, see <https://www.gnu.org/licenses/>.
19+
#
20+
################################################################################
21+
#
22+
# firmware code:
23+
# - https://github.com/RIOT-OS/RIOT
24+
#
25+
################################################################################
26+
27+
ROOT_DIR_NAME := $(notdir $(realpath $(dir $(lastword $(MAKEFILE_LIST)))))
28+
29+
include ../constant.mk
30+
31+
SRC := $(ENV_SRC_DIR)/$(ROOT_DIR_NAME)
32+
BUILD := $(ENV_BUILDS_DIR)/$(ROOT_DIR_NAME)
33+
34+
OBJCOPY = $(TOOLCHAIN_ARM_GNU_13_2_REL1_OBJCOPY)
35+
READELF := $(TOOLCHAIN_ARM_GNU_13_2_REL1_READELF)
36+
37+
GIT_TAG_RIOT_OS_RIOT := 2018.04
38+
GIT_COMMIT_RIOT_OS_RIOT := 99b170d8e8788edc49aa23248effbaeb1a1183d5
39+
TARGET := default
40+
FW_ELF := $(BUILD)/$(TARGET).elf
41+
42+
43+
.PHONY: all firmware_build firmware_metadata_gen clean_src clean release
44+
45+
46+
all: firmware_build firmware_metadata_gen clean_src
47+
48+
49+
release: all
50+
51+
52+
firmware_build:
53+
mkdir -p $(BUILD) $(SRC)
54+
55+
# Firmware source code bootstrap.
56+
$(SCRIPT_BOOTSTRAP_GIT_ARCHIVE) \
57+
$(ENV_ARCHIVES_DIR)/$(REPO_RIOT_OS_RIOT).tar.gz $(SRC) $(GIT_TAG_RIOT_OS_RIOT)
58+
59+
# Firmware build.
60+
rm -rf $(SRC)/$(REPO_RIOT_OS_RIOT)/examples/default/bin
61+
cd $(SRC)/$(REPO_RIOT_OS_RIOT)/examples/default \
62+
&& $(MAKE) WERROR=0 BOARD=frdm-k64f PATH=$(TOOLCHAIN_ARM_GNU_13_2_REL1_PATH_BASE):$(PATH)
63+
cp -v $(SRC)/$(REPO_RIOT_OS_RIOT)/examples/default/bin/frdm-k64f/$(TARGET).* $(BUILD)
64+
$(OBJCOPY) -O binary $(BUILD)/$(TARGET).elf $(BUILD)/default.bin
65+
66+
67+
firmware_metadata_gen: $(FW_ELF)
68+
variant=$$($(READELF) -A $(FW_ELF) |tr -d ' '|grep -Po '(?<=Tag_CPU_arch:).*'); \
69+
entry_point=$$($(READELF) -h $(FW_ELF) |grep 'Entry point address:' |grep -Po '0x[0-9a-fA-F]*'); \
70+
blob_size=$$(stat --printf=%s $(BUILD)/$(TARGET).bin); \
71+
blob_base_addr=0x$$($(READELF) -s $(FW_ELF) |grep '\.vector' |grep -Po '[0-9a-fA-F]{8}'); \
72+
blob_endian=$$($(READELF) -h $(FW_ELF) |grep 'Data:' |grep -Po '(little|big) endian' |grep -Po '(little|big)'); \
73+
blob_sha1=$$(sha1sum $(BUILD)/$(TARGET).bin |cut -d " " -f 1) \
74+
; \
75+
$(PYTHON) $(SCRIPT_FW_JSON_META_PY) \
76+
firmware_load_meta \
77+
--processor-id main \
78+
--processor arm \
79+
--processor-variant $$variant \
80+
--processor-model MK64FN1M0VLL12 \
81+
--entry-point $$entry_point \
82+
--load $(TARGET).bin 0x0 $$blob_size $$blob_base_addr \
83+
--out $(BUILD)/firmware_load_metadata.json \
84+
; \
85+
$(PYTHON) $(SCRIPT_FW_JSON_META_PY) \
86+
firmware_build_meta \
87+
--filename $(TARGET).bin \
88+
--file-size $$blob_size \
89+
--sha1 $$blob_sha1 \
90+
--endian $$blob_endian \
91+
--operating-system RIOT \
92+
--compiler gcc \
93+
--toolchain $(TOOLCHAIN_ARM_GNU_13_2_REL1) \
94+
--processor arm \
95+
--processor-variant $$variant \
96+
--processor-model MK64FN1M0VLL12 \
97+
--entry-point $$entry_point \
98+
--src "$(REPO_RIOT_OS_RIOT_URL)" $(GIT_COMMIT_RIOT_OS_RIOT) \
99+
--out $(BUILD)/$(TARGET).json
100+
101+
$(PYTHON) $(SCRIPT_FW_JSON_META_PY) \
102+
firmware_all_meta \
103+
--board frdm-64-MK64FN1M0VLL12 \
104+
--load-meta-file $(BUILD)/firmware_load_metadata.json \
105+
--firmware-build-meta-file $(BUILD)/$(TARGET).json \
106+
--out $(BUILD)/firmware_metadata.json
107+
108+
rm -f $(BUILD)/firmware_load_metadata.json $(BUILD)/$(TARGET).json
109+
110+
111+
clean_src:
112+
rm -rf $(SRC)
113+
114+
115+
clean:
116+
rm -rf $(BUILD) $(SRC)

builders/Makefile

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
################################################################################
2+
#
3+
# Copyright 2023-2024 Vincent Dary
4+
#
5+
# This file is part of open-firmware-dataset-builder (OFDB).
6+
#
7+
# open-firmware-dataset-builder is free software: you can redistribute it and/or
8+
# modify it under the terms of the GNU General Public License as published by
9+
# the Free Software Foundation, either version 3 of the License, or (at your
10+
# option) any later version.
11+
#
12+
# open-firmware-dataset-builder is distributed in the hope that it will be
13+
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15+
# Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License along with
18+
# open-firmware-dataset-builder. If not, see <https://www.gnu.org/licenses/>.
19+
#
20+
################################################################################
21+
22+
RELEASE_BASE_DIR := ../releases
23+
RELEASE_VER := 1.0.0
24+
RELEASE_DIR_NAME := open-firmware-dataset-V$(RELEASE_VER)
25+
RELEASE_DIR := $(RELEASE_BASE_DIR)/$(RELEASE_DIR_NAME)
26+
RELEASE_ARCHIVE_NAME := $(RELEASE_DIR_NAME).tar.gz
27+
RELEASE_NOTE_FILE := $(RELEASE_DIR)/README.txt
28+
RELEASE_LICENCE := ../data/odf_cc_by-nc-nd_4.0_legalcode.txt
29+
RELEASE_NOTE := ../data/ofd_release_notes.txt
30+
RELEASE_VERSION_BANNER := "\n\nOpen Firmware Dataset (OFD) - version $(RELEASE_VER)"
31+
32+
33+
SUB_DIRS := $(shell find . -type d -not -path ".")
34+
35+
36+
all: $(SUB_DIRS)
37+
38+
39+
clean: $(SUB_DIRS)
40+
41+
42+
release: $(RELEASE_BASE_DIR)/$(RELEASE_ARCHIVE_NAME)
43+
44+
45+
$(RELEASE_BASE_DIR)/$(RELEASE_ARCHIVE_NAME): $(SUB_DIRS)
46+
rm -rf $(RELEASE_DIR)
47+
mkdir $(RELEASE_DIR)
48+
mv ../builds $(RELEASE_DIR)
49+
mkdir ../builds
50+
echo -e $(RELEASE_VERSION_BANNER) > $(RELEASE_NOTE_FILE)
51+
cat $(RELEASE_NOTE) >> $(RELEASE_NOTE_FILE)
52+
cp -v $(RELEASE_LICENCE) $(RELEASE_DIR)/License
53+
cd $(RELEASE_BASE_DIR) && tar -czf $(RELEASE_ARCHIVE_NAME) $(RELEASE_DIR_NAME)
54+
cd $(RELEASE_BASE_DIR) && rm -rf $(RELEASE_DIR_NAME)
55+
56+
57+
$(SUB_DIRS):
58+
$(MAKE) -C $@ $(MAKECMDGOALS)
59+
60+
61+
.PHONY: all clean $(SUB_DIRS)
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
################################################################################
2+
#
3+
# Copyright 2023-2024 Vincent Dary
4+
#
5+
# This file is part of open-firmware-dataset-builder (OFDB).
6+
#
7+
# open-firmware-dataset-builder is free software: you can redistribute it and/or
8+
# modify it under the terms of the GNU General Public License as published by
9+
# the Free Software Foundation, either version 3 of the License, or (at your
10+
# option) any later version.
11+
#
12+
# open-firmware-dataset-builder is distributed in the hope that it will be
13+
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15+
# Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License along with
18+
# open-firmware-dataset-builder. If not, see <https://www.gnu.org/licenses/>.
19+
#
20+
################################################################################
21+
#
22+
# firmware code:
23+
# - https://github.com/deadsy/grbl_stm32f4
24+
#
25+
################################################################################
26+
27+
ROOT_DIR_NAME := $(notdir $(realpath $(dir $(lastword $(MAKEFILE_LIST)))))
28+
29+
include ../constant.mk
30+
31+
SRC := $(ENV_SRC_DIR)/$(ROOT_DIR_NAME)
32+
BUILD := $(ENV_BUILDS_DIR)/$(ROOT_DIR_NAME)
33+
34+
READELF := $(TOOLCHAIN_ARM_GNU_13_2_REL1_READELF)
35+
36+
GIT_COMMIT_DEADSY_GRBL_STM32F4 := a5246c935380178df1b362e61eefd32acd6c8024
37+
TARGET := grbl_stm32f4
38+
FW_ELF := $(BUILD)/$(TARGET).elf
39+
40+
41+
.PHONY: all firmware_build firmware_metadata_gen clean_src clean release
42+
43+
44+
all: firmware_build firmware_metadata_gen clean_src
45+
46+
47+
release: all
48+
49+
50+
firmware_build:
51+
mkdir -p $(BUILD) $(SRC)
52+
53+
$(SCRIPT_BOOTSTRAP_GIT_ARCHIVE) \
54+
$(ENV_ARCHIVES_DIR)/$(REPO_DEADSY_GRBL_STM32F4).tar.gz $(SRC) \
55+
$(GIT_COMMIT_DEADSY_GRBL_STM32F4)
56+
57+
cd $(SRC)/$(REPO_DEADSY_GRBL_STM32F4) \
58+
&& awk 'NR==3 {$$0="XTOOLS_DIR = ../$(TOOLCHAIN_ARM_GNU_13_2_REL1_PATH)"} { print }' Makefile \
59+
> Makefile_PATCH.mk
60+
61+
cd $(SRC)/$(REPO_DEADSY_GRBL_STM32F4) && make -f Makefile_PATCH.mk
62+
63+
cp -v $(SRC)/$(REPO_DEADSY_GRBL_STM32F4)/$(TARGET)* $(BUILD)
64+
mv $(BUILD)/$(TARGET) $(FW_ELF)
65+
66+
67+
firmware_metadata_gen: $(FW_ELF)
68+
variant=$$($(READELF) -A $(FW_ELF) |tr -d ' '|grep -Po '(?<=Tag_CPU_arch:).*'); \
69+
entry_point=$$($(READELF) -h $(FW_ELF) |grep 'Entry point address:' |grep -Po '0x[0-9a-fA-F]*'); \
70+
blob_size=$$(stat --printf=%s $(BUILD)/$(TARGET).bin); \
71+
blob_base_addr=0x$$($(READELF) -s $(FW_ELF) |grep '\.isr_vector' |grep -Po '[0-9a-fA-F]{8}'); \
72+
blob_endian=$$($(READELF) -h $(FW_ELF) |grep 'Data:' |grep -Po '(little|big) endian' |grep -Po '(little|big)'); \
73+
blob_sha1=$$(sha1sum $(BUILD)/$(TARGET).bin |cut -d " " -f 1) \
74+
; \
75+
$(PYTHON) $(SCRIPT_FW_JSON_META_PY) \
76+
firmware_load_meta \
77+
--processor-id main \
78+
--processor arm \
79+
--processor-variant $$variant \
80+
--processor-model STM32F407VG \
81+
--entry-point $$entry_point \
82+
--load $(TARGET).bin 0x0 $$blob_size $$blob_base_addr \
83+
--out $(BUILD)/firmware_load_metadata.json \
84+
; \
85+
$(PYTHON) $(SCRIPT_FW_JSON_META_PY) \
86+
firmware_build_meta \
87+
--filename $(TARGET).bin \
88+
--file-size $$blob_size \
89+
--sha1 $$blob_sha1 \
90+
--endian $$blob_endian \
91+
--compiler gcc \
92+
--toolchain $(TOOLCHAIN_ARM_GNU_13_2_REL1_READELF) \
93+
--processor arm \
94+
--processor-variant $$variant \
95+
--processor-model STM32F407VG \
96+
--entry-point $$entry_point \
97+
--src "$(REPO_DEADSY_GRBL_STM32F4_URL)" $(GIT_COMMIT_DEADSY_GRBL_STM32F4) \
98+
--out $(BUILD)/$(TARGET).json
99+
100+
$(PYTHON) $(SCRIPT_FW_JSON_META_PY) \
101+
firmware_all_meta \
102+
--board STM32F4DISCOVERY \
103+
--load-meta-file $(BUILD)/firmware_load_metadata.json \
104+
--firmware-build-meta-file $(BUILD)/$(TARGET).json \
105+
--out $(BUILD)/firmware_metadata.json
106+
107+
rm -f $(BUILD)/firmware_load_metadata.json $(BUILD)/$(TARGET).json
108+
109+
110+
clean_src:
111+
rm -rf $(SRC)
112+
113+
114+
clean:
115+
rm -rf $(BUILD) $(SRC)

0 commit comments

Comments
 (0)