From 267db1c049054d894778a6d15b8be5818b352295 Mon Sep 17 00:00:00 2001 From: Penguin Date: Sat, 18 Dec 2021 15:24:23 -0600 Subject: [PATCH 1/2] adding to agent... --- igloo_agent/src/lib.rs | 62 ++++++ igloo_agent/src/main.rs | 4 - testaz/.igloo/target/samd21j18a/Makefile | 203 ------------------ .../target/samd21j18a/scripts/debug.gdb | 1 - .../.igloo/target/samd21j18a/scripts/push.gdb | 1 - .../target/samd21j18a/scripts/samd21j18a.cfg | 12 -- testaz/ESF/cfg | 1 - testaz/ESF/common | 1 - testaz/ESF/ld | 1 - testaz/ESF/mcu | 1 - testaz/inc/igloo.h | 3 - testaz/src/main.c | 7 - 12 files changed, 62 insertions(+), 235 deletions(-) create mode 100644 igloo_agent/src/lib.rs delete mode 100644 igloo_agent/src/main.rs delete mode 100644 testaz/.igloo/target/samd21j18a/Makefile delete mode 120000 testaz/.igloo/target/samd21j18a/scripts/debug.gdb delete mode 120000 testaz/.igloo/target/samd21j18a/scripts/push.gdb delete mode 100644 testaz/.igloo/target/samd21j18a/scripts/samd21j18a.cfg delete mode 120000 testaz/ESF/cfg delete mode 120000 testaz/ESF/common delete mode 120000 testaz/ESF/ld delete mode 120000 testaz/ESF/mcu delete mode 100644 testaz/inc/igloo.h delete mode 100644 testaz/src/main.c diff --git a/igloo_agent/src/lib.rs b/igloo_agent/src/lib.rs new file mode 100644 index 0000000..83cba60 --- /dev/null +++ b/igloo_agent/src/lib.rs @@ -0,0 +1,62 @@ +use std::io::{BufRead, BufReader}; +use std::process::{Command, Stdio}; +use std::sync::mpsc::{channel, Sender}; +use std::thread; + +fn openocd_thread(sender: &Sender, child: std::process::Child) +{ + let mut f = BufReader::new(child.stdout.unwrap()); + loop + { + let mut buf = String::new(); + match f.read_line(&mut buf) + { + Ok(_) => + { + if !buf.is_empty() + { + sender.send(buf).unwrap(); + } + } + Err(e) => println!("error: {:?}", e), + } + } +} + +fn gdb_thread(sender: &Sender, child: std::process::Child) +{ + let mut f = BufReader::new(child.stdout.unwrap()); + loop + { + let mut buf = String::new(); + match f.read_line(&mut buf) + { + Ok(_) => + { + if !buf.is_empty() + { + sender.send(buf).unwrap(); + } + } + Err(e) => println!("error: {:?}", e), + } + } +} + +fn start_openocd_listener(sender: &Sender, board_cfg_file: &str) +{ + let child = Command::new("openocd") + .args(["-f", board_cfg_file]) + .stdout(Stdio::piped()) + .spawn() + .expect("Failed to start openocd process"); + + println!("Started openocd process: {}", child.id()); + + thread::spawn(move || openocd_thread(sender, child)); +} + +fn ia_push(target: &IglooTarget) -> Result< +{ + +} diff --git a/igloo_agent/src/main.rs b/igloo_agent/src/main.rs deleted file mode 100644 index 7da3a48..0000000 --- a/igloo_agent/src/main.rs +++ /dev/null @@ -1,4 +0,0 @@ - -fn main() { - println!("Hello, world!"); -} diff --git a/testaz/.igloo/target/samd21j18a/Makefile b/testaz/.igloo/target/samd21j18a/Makefile deleted file mode 100644 index 8b873ea..0000000 --- a/testaz/.igloo/target/samd21j18a/Makefile +++ /dev/null @@ -1,203 +0,0 @@ -# ePenguin Generated Variables -PROJECT_NAME=testaz -TARGET_NAME=samd21j18a -TOOLCHAIN=${ESF_DIR}/toolchains/arm-none-eabi-toolchain/bin/arm-none-eabi -CC=${TOOLCHAIN}-gcc -CXX=${TOOLCHAIN}-g++ -OBJCOPY=${TOOLCHAIN}-objcopy -OBJDUMP=${TOOLCHAIN}-objdump -GDB=${TOOLCHAIN}-gdb-py -SIZE=${TOOLCHAIN}-size -AS=${TOOLCHAIN}-as - - -MCPU=cortex-m0plus -MCU=__SAMD21J18A__ -LD_PATH=../../../ESF/ld -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 \ --MF$(QUOTE)$(@:%.o=%.d)$(QUOTE) \ --MT$(QUOTE)$(@:%.o=%.d)$(QUOTE) \ --MT$(QUOTE)$(@:%.o=%.o)$(QUOTE) - -ELF_FLAGS= \ --Wl,--start-group -l m \ --Wl,--end-group -mthumb \ --Wl,-Map=$(QUOTE)$(PROJECT_NAME).map$(QUOTE) \ ---specs=nano.specs \ --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 - MK_DIR = mkdir -else - ifeq ($(shell uname), Linux) - MK_DIR = mkdir -p - endif - - ifeq ($(shell uname | cut -d _ -f 1), CYGWIN) - MK_DIR = mkdir -p - endif - - ifeq ($(shell uname | cut -d _ -f 1), MINGW32) - MK_DIR = mkdir -p - endif - - ifeq ($(shell uname | cut -d _ -f 1), MINGW64) - MK_DIR = mkdir -p - endif - - ifeq ($(shell uname | cut -d _ -f 1), DARWIN) - 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) - -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_AS_ARGS:%.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) - - -$(PROJECT_NAME).elf:\ -$(OBJS) - $(QUOTE)$(CC)$(QUOTE) -o $@ $(OBJS_AS_ARGS) $(ELF_FLAGS) - - -$(PROJECT_NAME).bin:\ -$(PROJECT_NAME).elf - $(QUOTE)$(OBJCOPY)$(QUOTE) -O binary $(QUOTE)$<$(QUOTE) $(QUOTE)$@$(QUOTE) - - -$(PROJECT_NAME).hex:\ -$(PROJECT_NAME).elf - $(QUOTE)$(OBJCOPY)$(QUOTE) -O ihex $(HEX_FLAGS) $(QUOTE)$<$(QUOTE) $(QUOTE)$@$(QUOTE) - - -$(PROJECT_NAME).eep:\ -$(PROJECT_NAME).elf - $(QUOTE)$(OBJCOPY)$(QUOTE) $(EEP_FLAGS) -O binary $(QUOTE)$<$(QUOTE) $(QUOTE)$@$(QUOTE) || exit 0 - - -$(PROJECT_NAME).lss:\ -$(PROJECT_NAME).elf - $(QUOTE)$(OBJDUMP)$(QUOTE) -h -S $(QUOTE)$<$(QUOTE) > $(QUOTE)$@$(QUOTE) - - -# Compiler targets -%.o: %.c - @echo Building file: $< - @echo ARM/GNU C Compiler - $(QUOTE)$(CC)$(QUOTE) $(CFLAGS) -o $(QUOTE)$@$(QUOTE) $(QUOTE)$<$(QUOTE) - @echo Finished building: $< - -%.o: %.s - @echo Building file: $< - @echo ARM/GNU Assembler - $(QUOTE)$(AS)$(QUOTE) $(CFLAGS) -o $(QUOTE)$@$(QUOTE) $(QUOTE)$<$(QUOTE) - @echo Finished building: $< - -%.o: %.S - @echo Building file: $< - @echo ARM/GNU Preprocessing Assembler - $(QUOTE)$(CC)$(QUOTE) $(CFLAGS) -o $(QUOTE)$@$(QUOTE) $(QUOTE)$<$(QUOTE) - @echo Finished building: $< - - -$(SUB_DIRS): - $(MK_DIR) $(QUOTE)$@$(QUOTE) - -ifneq ($(MAKECMDGOALS),clean) -ifneq ($(strip $(DEPS)),) --include $(DEPS) -endif -endif - -clean: - @rm -f $(PROJECT_NAME).a - @rm -f $(PROJECT_NAME).lss - @rm -f $(PROJECT_NAME).srec - @rm -f $(PROJECT_NAME).map - @rm -f $(PROJECT_NAME).eep - @rm -f $(OBJS_AS_ARGS) - @rm -f $(DEPS_AS_ARGS) - @rm -f $(PROJECT_NAME).bin - @rm -f $(PROJECT_NAME).elf - @rm -f $(PROJECT_NAME).hex - - -debug:\ -all - @$(GDB) $(PROJECT_NAME).elf -x $(QUOTE)scripts/debug.gdb$(QUOTE) - - -push:\ -all - @echo $(QUOTE)$(QUOTE) - @echo $(QUOTE)Uploading $(PROJECT_NAME).elf...$(QUOTE) - @$(GDB) $(PROJECT_NAME).elf -x $(QUOTE)scripts/push.gdb$(QUOTE) >/dev/null - @echo $(QUOTE)$(QUOTE)$(PROJECT_NAME).elf $(QUOTE) uploaded!$(QUOTE) - @$(QUOTE)$(SIZE)$(QUOTE) $(QUOTE)$(PROJECT_NAME).elf$(QUOTE) - - -QUOTE:=" diff --git a/testaz/.igloo/target/samd21j18a/scripts/debug.gdb b/testaz/.igloo/target/samd21j18a/scripts/debug.gdb deleted file mode 120000 index ca77132..0000000 --- a/testaz/.igloo/target/samd21j18a/scripts/debug.gdb +++ /dev/null @@ -1 +0,0 @@ -/home/penguin/Documents/projects/ePenguin-Software-Framework/scripts/debug.gdb \ No newline at end of file diff --git a/testaz/.igloo/target/samd21j18a/scripts/push.gdb b/testaz/.igloo/target/samd21j18a/scripts/push.gdb deleted file mode 120000 index 5ad6114..0000000 --- a/testaz/.igloo/target/samd21j18a/scripts/push.gdb +++ /dev/null @@ -1 +0,0 @@ -/home/penguin/Documents/projects/ePenguin-Software-Framework/scripts/push.gdb \ No newline at end of file diff --git a/testaz/.igloo/target/samd21j18a/scripts/samd21j18a.cfg b/testaz/.igloo/target/samd21j18a/scripts/samd21j18a.cfg deleted file mode 100644 index b6139e0..0000000 --- a/testaz/.igloo/target/samd21j18a/scripts/samd21j18a.cfg +++ /dev/null @@ -1,12 +0,0 @@ -# -# ePenguin Generated OpenOCD Config Script -# - - -# Transport Select -source [find interface/jlink.cfg] -transport select swd - -# Chip Information -set CHIPNAME samd21j18a -source [find target/at91samdXX.cfg] diff --git a/testaz/ESF/cfg b/testaz/ESF/cfg deleted file mode 120000 index fa00e89..0000000 --- a/testaz/ESF/cfg +++ /dev/null @@ -1 +0,0 @@ -/home/penguin/Documents/projects/ePenguin-Software-Framework/arch/arm/SAMD21/SAMD21A/manifest/ \ No newline at end of file diff --git a/testaz/ESF/common b/testaz/ESF/common deleted file mode 120000 index 6fe6cd6..0000000 --- a/testaz/ESF/common +++ /dev/null @@ -1 +0,0 @@ -/home/penguin/Documents/projects/ePenguin-Software-Framework/arch/arm/common \ No newline at end of file diff --git a/testaz/ESF/ld b/testaz/ESF/ld deleted file mode 120000 index 5698f84..0000000 --- a/testaz/ESF/ld +++ /dev/null @@ -1 +0,0 @@ -/home/penguin/Documents/projects/ePenguin-Software-Framework/arch/arm/SAMD21/SAMD21A/ld/ \ No newline at end of file diff --git a/testaz/ESF/mcu b/testaz/ESF/mcu deleted file mode 120000 index 2aaa3f8..0000000 --- a/testaz/ESF/mcu +++ /dev/null @@ -1 +0,0 @@ -/home/penguin/Documents/projects/ePenguin-Software-Framework/arch/arm/SAMD21/SAMD21A/mcu/ \ No newline at end of file diff --git a/testaz/inc/igloo.h b/testaz/inc/igloo.h deleted file mode 100644 index 6f13af5..0000000 --- a/testaz/inc/igloo.h +++ /dev/null @@ -1,3 +0,0 @@ -#ifdef __SAMD21J18A__ - #include "sam.h" -#endif diff --git a/testaz/src/main.c b/testaz/src/main.c deleted file mode 100644 index 67672b3..0000000 --- a/testaz/src/main.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "igloo.h" - - -int main() -{ - return 0; -} From c7e7a1da83f46213b7c280e8db264402d1c89195 Mon Sep 17 00:00:00 2001 From: Penguin Date: Sat, 18 Dec 2021 16:18:43 -0600 Subject: [PATCH 2/2] accidentally worked in stable branch oops --- Cargo.lock | 4 ++++ igloo_agent/Cargo.toml | 2 ++ igloo_agent/src/lib.rs | 10 ++++++---- igloo_core/src/lib.rs | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cef2fc0..82ed5db 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -181,6 +181,10 @@ dependencies = [ [[package]] name = "igloo_agent" version = "0.1.0" +dependencies = [ + "igloo_base", + "igloo_core", +] [[package]] name = "igloo_base" diff --git a/igloo_agent/Cargo.toml b/igloo_agent/Cargo.toml index 8bd8a21..5b40001 100644 --- a/igloo_agent/Cargo.toml +++ b/igloo_agent/Cargo.toml @@ -7,3 +7,5 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +igloo_base = {path = "../igloo_base"} +igloo_core = {path = "../igloo_core"} \ No newline at end of file diff --git a/igloo_agent/src/lib.rs b/igloo_agent/src/lib.rs index 83cba60..2364926 100644 --- a/igloo_agent/src/lib.rs +++ b/igloo_agent/src/lib.rs @@ -3,7 +3,9 @@ use std::process::{Command, Stdio}; use std::sync::mpsc::{channel, Sender}; use std::thread; -fn openocd_thread(sender: &Sender, child: std::process::Child) +use igloo_base::*; +use igloo_core::igloo_target; +fn openocd_thread(sender: Sender, child: std::process::Child) { let mut f = BufReader::new(child.stdout.unwrap()); loop @@ -43,7 +45,7 @@ fn gdb_thread(sender: &Sender, child: std::process::Child) } } -fn start_openocd_listener(sender: &Sender, board_cfg_file: &str) +fn start_openocd_listener(sender: Sender, board_cfg_file: &str) { let child = Command::new("openocd") .args(["-f", board_cfg_file]) @@ -56,7 +58,7 @@ fn start_openocd_listener(sender: &Sender, board_cfg_file: &str) thread::spawn(move || openocd_thread(sender, child)); } -fn ia_push(target: &IglooTarget) -> Result< +fn ia_push(target: &igloo_target::IglooTarget) -> Result { - + Ok(String::from("working")) } diff --git a/igloo_core/src/lib.rs b/igloo_core/src/lib.rs index 5be835e..97e700e 100644 --- a/igloo_core/src/lib.rs +++ b/igloo_core/src/lib.rs @@ -6,7 +6,7 @@ extern crate config; mod igloo_action; mod igloo_project; -mod igloo_target; +pub mod igloo_target; use igloo_base::*; use igloo_base::IglooInstType::*;