bug fixes and readability improvements

stable
penguin 4 years ago
parent a2aee475ea
commit 1b8ac7bbcf

@ -4,20 +4,20 @@
[arch]
QUOTE = "\""
PROJECT_NAME = "Default Project Name"
PROJECT_NAME = "d21test"
DIR_INCLUDES = ["-I$(QUOTE)../ESF/mcu/inc$(QUOTE)",
"-I$(QUOTE)../inc$(QUOTE)"]
DEPS = "$(OBJS:%.o=%.d)"
DEPS_AS_ARGS = "$(OBJS:%.o=%.d)"
OBJS = ["src/main.o"]
OBJS_AS_ARGS = ["$(QUOTE)src/main.o$(QUOTE)", "."]
OBJS_AS_ARGS = ["$(QUOTE)src/main.o$(QUOTE)"]
CLEAN_PREREQS = [""]
CLEAN_CMDS = ["rm -f $(OBJS_AS_ARGS)",
"rm -f $(DEPS_AS_ARGS)"]
[arch.arm]
TOOLCHAIN = "${ESF_DIR}/toolchain/arm/bin/arm-none-eabi"
TOOLCHAIN = "${ESF_DIR}/toolchains/arm/bin/arm-none-eabi"
CC = "${TOOLCHAIN}-gcc"
CXX = "${TOOLCHAIN}-g++"
OBJCOPY = "${TOOLCHAIN}-objcopy"
@ -28,6 +28,7 @@ AS = "${TOOLCHAIN}-as"
CFLAGS = ["-x c", "-DDEBUG", "-Os",
"-g3",
"-Wall",
"-c",
"-std=gnu99",
"$(DIR_INCLUDES)",
"-MD -MP",
@ -35,13 +36,15 @@ CFLAGS = ["-x c", "-DDEBUG", "-Os",
"-MT$(QUOTE)$(@:%.o=%.d)$(QUOTE)",
"-MT$(QUOTE)$(@:%.o=%.o)$(QUOTE)"]
EFLAGS = ["-Wl,--start-group -l m",
ELF_FLAGS = ["-Wl,--start-group -l m",
"-Wl,--end-group -mthumb",
"-Wl,-Map=$(QUOTE)$(PROJECT_NAME).map$(QUOTE)",
"--specs=nano.specs",
"-Wl,--gc-sections"]
"-Wl,--gc-sections",
"-T$(QUOTE)$(LD_SCRIPT)$(QUOTE)",
"-L$(QUOTE)$(LD_PATH)$(QUOTE)"]
HFLAGS = ["-R .eeprom",
HEX_FLAGS = ["-R .eeprom",
"-R .fuse",
"-R .lock",
"-R .signature"]
@ -52,16 +55,17 @@ EEP_FLAGS = ["-j .eeprom --set-section-flags=.eeprom=alloc,load",
LD_PATH = "../ESF/ld"
DIR_INCLUDES = ["-I$(QUOTE)../ESF/common/inc$(QUOTE)",
"-I$(QUOTE)../ESF/common/inc/cmsis$(QUOTE)"]
BUILD_PREREQ = ["$(SUB_DIRS)",
"$(PROJECT_NAME).elf)",
"$(PROJECT_NAME).bin)",
"$(PROJECT_NAME).hex)",
"$(PROJECT_NAME).eep)",
"$(PROJECT_NAME).lss)"]
BUILD_CMDS = ["$(QUOTE)$(SIZE)$(QUOTE) $(QUOTE)$(PROJECT_NAME).elf$(QUOTE)"]
ALL_PREREQS = ["$(SUB_DIRS)",
"$(PROJECT_NAME).elf",
"$(PROJECT_NAME).bin",
"$(PROJECT_NAME).hex",
"$(PROJECT_NAME).eep",
"$(PROJECT_NAME).lss"]
ALL_CMDS = ["$(QUOTE)$(SIZE)$(QUOTE) $(QUOTE)$(PROJECT_NAME).elf$(QUOTE)"]
SUB_DIRS = ["src", "ESF/mcu/src"]
[arch.arm.samd21a]
MCPU = "cortex-m0plus"
CFLAGS = ["-D$(MCU)", "-mcpu=$(MCPU)"]
[arch.arm.samd21a.samd21e15a]
[arch.arm.samd21a.samd21e16a]
[arch.arm.samd21a.samd21e17a]

@ -1,10 +1,11 @@
# ePenguin Generated Variables
TOOLCHAIN=${ESF_DIR}/toolchain/arm/bin/arm-none-eabi
PROJECT_NAME=d21test
TOOLCHAIN=${ESF_DIR}/toolchains/arm/bin/arm-none-eabi
CC=${TOOLCHAIN}-gcc
CXX=${TOOLCHAIN}-g++
OBJCOPY=${TOOLCHAIN}-objcopy
OBJDUMP=${TOOLCHAIN}-objdump
OBJDUMP=${TOOLCHAIN}-gdb
GDB=${TOOLCHAIN}-gdb
SIZE=${TOOLCHAIN}-size
AS=${TOOLCHAIN}-as
@ -16,11 +17,14 @@ LD_SCRIPT=$(LD_PATH)/samd21j18a_flash.ld
CFLAGS= \
-D$(MCU) \
-mcpu=$(MCPU) \
-x c \
-DDEBUG \
-Os \
-g3 \
-Wall \
-c \
-std=gnu99 \
$(DIR_INCLUDES) \
-MD -MP \
@ -28,12 +32,26 @@ $(DIR_INCLUDES) \
-MT$(QUOTE)$(@:%.o=%.d)$(QUOTE) \
-MT$(QUOTE)$(@:%.o=%.o)$(QUOTE)
EFLAGS= \
ELF_FLAGS= \
-Wl,--start-group -l m \
-Wl,--end-group -mthumb \
-Wl,-Map=$(QUOTE)$(PROJECT_NAME).map$(QUOTE) \
--specs=nano.specs \
-Wl,--gc-sections
-Wl,--gc-sections \
-T$(QUOTE)$(LD_SCRIPT)$(QUOTE) \
-L$(QUOTE)$(LD_PATH)$(QUOTE)
HEX_FLAGS= \
-R .eeprom \
-R .fuse \
-R .lock \
-R .signature
EEP_FLAGS= \
-j .eeprom --set-section-flags=.eeprom=alloc,load \
--change-section-lma \
.eeprom=0 \
--no-change-warnings
ifdef SystemRoot
SHELL = cmd.exe
@ -60,16 +78,42 @@ MK_DIR = mkdir -p
endif
endif
SUB_DIRS+= \
src \
ESF/mcu/src
OBJS+= \
ESF/mcu/src/startup_samd21j18a.o \
ESF/mcu/src/system_samd21j18a.o \
src/main.o
OBJS_AS_ARGS+= \
$(QUOTE)ESF/mcu/src/startup_samd21j18a.o$(QUOTE) \
$(QUOTE)ESF/mcu/src/system_samd21j18a.o$(QUOTE) \
$(QUOTE)src/main.o$(QUOTE) \
.
$(QUOTE)src/main.o$(QUOTE)
DIR_INCLUDES+= \
-I$(QUOTE)../ESF/common/inc$(QUOTE) \
-I$(QUOTE)../ESF/common/inc/cmsis$(QUOTE) \
-I$(QUOTE)../ESF/mcu/inc$(QUOTE) \
-I$(QUOTE)../inc$(QUOTE)
DEPS:=$(OBJS:%.o=%.d)
DEPS_AS_ARGS:=$(OBJS:%.o=%.d)
vpath %.c ../
vpath %.s ../
vpath %.S ../
.PHONY: debug clean
all:\
$(SUB_DIRS)\
$(PROJECT_NAME).elf\
$(PROJECT_NAME).bin\
$(PROJECT_NAME).hex\
$(PROJECT_NAME).eep\
$(PROJECT_NAME).lss
\
$(QUOTE)$(SIZE)$(QUOTE) $(QUOTE)$(PROJECT_NAME).elf$(QUOTE)

@ -80,6 +80,19 @@ fn gen_makefile(mkfile: &HashMap<String, config::Value>) -> bool
writeln!(app_file, "# ePenguin Generated Variables").unwrap();
// Get our knowns out of the way
match mkfile.get("PROJECT_NAME")
{
None =>
{
println!("PROJECT_NAME not found");
}
Some(v) =>
{
write!(app_file, "PROJECT_NAME=").unwrap();
writeln!(app_file, "{}", v.to_string()).unwrap();
},
}
match mkfile.get("TOOLCHAIN")
{
None =>
@ -148,7 +161,7 @@ fn gen_makefile(mkfile: &HashMap<String, config::Value>) -> bool
}
Some(v) =>
{
write!(app_file, "OBJDUMP=").unwrap();
write!(app_file, "GDB=").unwrap();
writeln!(app_file, "{}", v.to_string()).unwrap();
},
}
@ -249,15 +262,51 @@ fn gen_makefile(mkfile: &HashMap<String, config::Value>) -> bool
}
writeln!(app_file, "\n").unwrap();
// ELF FLAGS
match mkfile.get("EFLAGS")
match mkfile.get("ELF_FLAGS")
{
None =>
{
println!("ELF_FLAGS Not found");
}
Some(v) =>
{
write!(app_file, "ELF_FLAGS=").unwrap();
for cflag in v.clone().into_array().unwrap()
{
writeln!(app_file, " \\").unwrap();
write!(app_file, "{}", cflag).unwrap();
}
},
}
writeln!(app_file, "\n").unwrap();
// HEX FLAGS
match mkfile.get("HEX_FLAGS")
{
None =>
{
println!("HEX_FLAGS Not found");
}
Some(v) =>
{
write!(app_file, "HEX_FLAGS=").unwrap();
for cflag in v.clone().into_array().unwrap()
{
writeln!(app_file, " \\").unwrap();
write!(app_file, "{}", cflag).unwrap();
}
},
}
writeln!(app_file, "\n").unwrap();
match mkfile.get("EEP_FLAGS")
{
None =>
{
println!("EFLAGS Not found");
println!("EEP_FLAGS Not found");
}
Some(v) =>
{
write!(app_file, "EFLAGS=").unwrap();
write!(app_file, "EEP_FLAGS=").unwrap();
for cflag in v.clone().into_array().unwrap()
{
writeln!(app_file, " \\").unwrap();
@ -294,7 +343,7 @@ endif\n\
endif\n\
");
writeln!(app_file, "{}\n", sysroot).unwrap();
writeln!(app_file, "{}", sysroot).unwrap();
match mkfile.get("SUB_DIRS")
{
None =>
@ -312,7 +361,7 @@ endif\n\
},
}
write!(app_file, "\n").unwrap();
writeln!(app_file, "\n").unwrap();
match mkfile.get("OBJS")
{
None =>
@ -330,7 +379,7 @@ endif\n\
},
}
write!(app_file, "\n").unwrap();
writeln!(app_file, "\n").unwrap();
match mkfile.get("OBJS_AS_ARGS")
{
None =>
@ -348,6 +397,92 @@ endif\n\
},
}
writeln!(app_file, "\n").unwrap();
match mkfile.get("DIR_INCLUDES")
{
None =>
{
println!("DIR_INCLUDES Not found");
}
Some(v) =>
{
write!(app_file, "DIR_INCLUDES+=").unwrap();
for cflag in v.clone().into_array().unwrap()
{
writeln!(app_file, " \\").unwrap();
write!(app_file, "{}", cflag).unwrap();
}
},
}
write!(app_file, "\n\n").unwrap();
match mkfile.get("DEPS")
{
None =>
{
println!("DEPS Not found");
}
Some(v) =>
{
write!(app_file, "DEPS:=").unwrap();
writeln!(app_file, "{}", v.to_string()).unwrap();
},
}
write!(app_file, "\n").unwrap();
match mkfile.get("DEPS_AS_ARGS")
{
None =>
{
println!("DEPS_AS_ARGS Not found");
}
Some(v) =>
{
write!(app_file, "DEPS_AS_ARGS:=").unwrap();
writeln!(app_file, "{}", v.to_string()).unwrap();
},
}
writeln!(app_file, "\nvpath %.c ../").unwrap();
writeln!(app_file, "vpath %.s ../").unwrap();
writeln!(app_file, "vpath %.S ../\n").unwrap();
writeln!(app_file, ".PHONY: debug clean\n").unwrap();
match mkfile.get("ALL_PREREQS")
{
None =>
{
println!("ALL_PREREQS Not found");
}
Some(v) =>
{
write!(app_file, "all:").unwrap();
for cflag in v.clone().into_array().unwrap()
{
writeln!(app_file, "\\").unwrap();
write!(app_file, "{}", cflag).unwrap();
}
},
}
match mkfile.get("ALL_CMDS")
{
None =>
{
println!("ALL_CMDS Not found");
}
Some(v) =>
{
write!(app_file, "\n\t").unwrap();
for cflag in v.clone().into_array().unwrap()
{
writeln!(app_file, "\\").unwrap();
write!(app_file, "\t{}", cflag).unwrap();
}
},
}
true
}

@ -1,4 +1,4 @@
{"message":"unused imports: `Environment`, `Value`","code":{"code":"unused_imports","explanation":null},"level":"warning","spans":[{"file_name":"src/main.rs","byte_start":21,"byte_end":32,"line_start":1,"line_end":1,"column_start":22,"column_end":33,"is_primary":true,"text":[{"text":"use config::{Config, Environment, Value};","highlight_start":22,"highlight_end":33}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"src/main.rs","byte_start":34,"byte_end":39,"line_start":1,"line_end":1,"column_start":35,"column_end":40,"is_primary":true,"text":[{"text":"use config::{Config, Environment, Value};","highlight_start":35,"highlight_end":40}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`#[warn(unused_imports)]` on by default","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"remove the unused imports","code":null,"level":"help","spans":[{"file_name":"src/main.rs","byte_start":19,"byte_end":39,"line_start":1,"line_end":1,"column_start":20,"column_end":40,"is_primary":true,"text":[{"text":"use config::{Config, Environment, Value};","highlight_start":20,"highlight_end":40}],"label":null,"suggested_replacement":"","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[33mwarning\u001b[0m\u001b[0m\u001b[1m: unused imports: `Environment`, `Value`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/main.rs:1:22\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m1\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0muse config::{Config, Environment, Value};\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[33m^^^^^^^^^^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[33m^^^^^\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: `#[warn(unused_imports)]` on by default\u001b[0m\n\n"}
{"message":"unused import: `toml::value`","code":{"code":"unused_imports","explanation":null},"level":"warning","spans":[{"file_name":"src/main.rs","byte_start":168,"byte_end":179,"line_start":7,"line_end":7,"column_start":5,"column_end":16,"is_primary":true,"text":[{"text":"use toml::value;","highlight_start":5,"highlight_end":16}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"remove the whole `use` item","code":null,"level":"help","spans":[{"file_name":"src/main.rs","byte_start":164,"byte_end":180,"line_start":7,"line_end":7,"column_start":1,"column_end":17,"is_primary":true,"text":[{"text":"use toml::value;","highlight_start":1,"highlight_end":17}],"label":null,"suggested_replacement":"","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[33mwarning\u001b[0m\u001b[0m\u001b[1m: unused import: `toml::value`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/main.rs:7:5\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m7\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0muse toml::value;\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[33m^^^^^^^^^^^\u001b[0m\n\n"}
{"message":"unused `std::result::Result` that must be used","code":{"code":"unused_must_use","explanation":null},"level":"warning","spans":[{"file_name":"src/main.rs","byte_start":1927,"byte_end":1960,"line_start":70,"line_end":70,"column_start":3,"column_end":36,"is_primary":true,"text":[{"text":"\t\tstd::fs::remove_file(\"Makefile\");","highlight_start":3,"highlight_end":36}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`#[warn(unused_must_use)]` on by default","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"this `Result` may be an `Err` variant, which should be handled","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[33mwarning\u001b[0m\u001b[0m\u001b[1m: unused `std::result::Result` that must be used\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/main.rs:70:3\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m70\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m std::fs::remove_file(\"Makefile\");\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[33m^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: `#[warn(unused_must_use)]` on by default\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: this `Result` may be an `Err` variant, which should be handled\u001b[0m\n\n"}
{"message":"unused `std::result::Result` that must be used","code":{"code":"unused_must_use","explanation":null},"level":"warning","spans":[{"file_name":"src/main.rs","byte_start":1830,"byte_end":1863,"line_start":69,"line_end":69,"column_start":3,"column_end":36,"is_primary":true,"text":[{"text":"\t\tstd::fs::remove_file(\"Makefile\");","highlight_start":3,"highlight_end":36}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`#[warn(unused_must_use)]` on by default","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"this `Result` may be an `Err` variant, which should be handled","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[33mwarning\u001b[0m\u001b[0m\u001b[1m: unused `std::result::Result` that must be used\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/main.rs:69:3\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m69\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m std::fs::remove_file(\"Makefile\");\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[33m^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: `#[warn(unused_must_use)]` on by default\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: this `Result` may be an `Err` variant, which should be handled\u001b[0m\n\n"}
{"message":"3 warnings emitted","code":null,"level":"warning","spans":[],"children":[],"rendered":"\u001b[0m\u001b[1m\u001b[33mwarning\u001b[0m\u001b[0m\u001b[1m: 3 warnings emitted\u001b[0m\n\n"}

Loading…
Cancel
Save