From e19c477875335a50b3c5a0b37e14a525726bd5b3 Mon Sep 17 00:00:00 2001 From: Samuel Sadok Date: Tue, 24 Apr 2018 19:36:07 -0700 Subject: [PATCH 01/16] add test property --- Firmware/communication/communication.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Firmware/communication/communication.cpp b/Firmware/communication/communication.cpp index ae611f24..1c4accfd 100644 --- a/Firmware/communication/communication.cpp +++ b/Firmware/communication/communication.cpp @@ -64,6 +64,8 @@ const uint8_t fw_version_unreleased = FW_VERSION_UNRELEASED; // 0 for official r osThreadId comm_thread; +static uint32_t test_property = 0; + /* Private function prototypes -----------------------------------------------*/ /* Function implementations --------------------------------------------------*/ @@ -134,8 +136,9 @@ static inline auto make_obj_tree() { ), make_protocol_object("axis0", axes[0]->make_protocol_definitions()), make_protocol_object("axis1", axes[1]->make_protocol_definitions()), - make_protocol_function("get_oscilloscope_val", static_functions, &StaticFunctions::get_oscilloscope_val, "index"), + make_protocol_property("test_property", &test_property), make_protocol_function("test_function", static_functions, &StaticFunctions::test_function, "delta"), + make_protocol_function("get_oscilloscope_val", static_functions, &StaticFunctions::get_oscilloscope_val, "index"), make_protocol_function("save_configuration", static_functions, &StaticFunctions::save_configuration_helper), make_protocol_function("erase_configuration", static_functions, &StaticFunctions::erase_configuration_helper), make_protocol_function("reboot", static_functions, &StaticFunctions::NVIC_SystemReset_helper), From 705d18885e815929fc1dc3c9f64ccc46cf4729d1 Mon Sep 17 00:00:00 2001 From: samuelsadok Date: Sat, 12 May 2018 22:05:35 -0700 Subject: [PATCH 02/16] disable -fstack-usage --- Firmware/build.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Firmware/build.lua b/Firmware/build.lua index 8ef67627..ac86d7aa 100644 --- a/Firmware/build.lua +++ b/Firmware/build.lua @@ -49,7 +49,8 @@ end function GCCToolchain(prefix, builddir, compiler_flags, linker_flags) -- add some default compiler flags - compiler_flags += '-fstack-usage' + -- This gives a warning for some functions containing inline assembly (prvPortStartFirstTask in particular) + --compiler_flags += '-fstack-usage' gcc_generic_compiler = function(compiler, compiler_flags, gen_su_file, src, flags, includes, outputs) -- convert include list to flags From 1375dd1b3261d52782cc1c73d4935cc561f5d27b Mon Sep 17 00:00:00 2001 From: Samuel Sadok Date: Sat, 12 May 2018 22:18:13 -0700 Subject: [PATCH 03/16] properly disable -fstack-usage --- Firmware/build.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Firmware/build.lua b/Firmware/build.lua index ac86d7aa..ea792219 100644 --- a/Firmware/build.lua +++ b/Firmware/build.lua @@ -49,8 +49,12 @@ end function GCCToolchain(prefix, builddir, compiler_flags, linker_flags) -- add some default compiler flags - -- This gives a warning for some functions containing inline assembly (prvPortStartFirstTask in particular) - --compiler_flags += '-fstack-usage' + -- -fstack-usage gives a warning for some functions containing inline assembly (prvPortStartFirstTask in particular) + -- so for now we just disable it + calculate_stack_usage = false + if calculate_stack_usage then + compiler_flags += '-fstack-usage' + end gcc_generic_compiler = function(compiler, compiler_flags, gen_su_file, src, flags, includes, outputs) -- convert include list to flags @@ -80,8 +84,8 @@ function GCCToolchain(prefix, builddir, compiler_flags, linker_flags) } end return { - compile_c = function(src, flags, includes, outputs) gcc_generic_compiler(prefix..'gcc -std=c99', compiler_flags, true, src, flags, includes, outputs) end, - compile_cpp = function(src, flags, includes, outputs) gcc_generic_compiler(prefix..'g++ -std=c++14', compiler_flags, true, src, flags, includes, outputs) end, + compile_c = function(src, flags, includes, outputs) gcc_generic_compiler(prefix..'gcc -std=c99', compiler_flags, calculate_stack_usage, src, flags, includes, outputs) end, + compile_cpp = function(src, flags, includes, outputs) gcc_generic_compiler(prefix..'g++ -std=c++14', compiler_flags, calculate_stack_usage, src, flags, includes, outputs) end, compile_asm = function(src, flags, includes, outputs) gcc_generic_compiler(prefix..'gcc -x assembler-with-cpp', compiler_flags, false, src, flags, includes, outputs) end, link = function(objects, output_name) output_name = builddir..'/'..output_name From 75a7c0b012f5673fec8cd98c2fee7489370f6761 Mon Sep 17 00:00:00 2001 From: Oskar Weigl Date: Sat, 12 May 2018 22:14:52 -0700 Subject: [PATCH 04/16] add strict suggestion to tup config default --- Firmware/.vscode/c_cpp_properties.json | 2 +- Firmware/tup.config.default | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Firmware/.vscode/c_cpp_properties.json b/Firmware/.vscode/c_cpp_properties.json index eab99cd5..4b0ce3bf 100644 --- a/Firmware/.vscode/c_cpp_properties.json +++ b/Firmware/.vscode/c_cpp_properties.json @@ -129,5 +129,5 @@ } } ], - "version": 3 + "version": 4 } \ No newline at end of file diff --git a/Firmware/tup.config.default b/Firmware/tup.config.default index 8ebb4402..60d2500d 100644 --- a/Firmware/tup.config.default +++ b/Firmware/tup.config.default @@ -3,3 +3,6 @@ #CONFIG_BOARD_VERSION=v3.5-24V CONFIG_USB_PROTOCOL=native CONFIG_UART_PROTOCOL=ascii + +# Uncomment this to error on compilation warnings +#CONFIG_STRICT=true From 1ace6422db5b050e269c707f01ae45d40d113c0b Mon Sep 17 00:00:00 2001 From: Oskar Weigl Date: Sat, 12 May 2018 22:20:41 -0700 Subject: [PATCH 05/16] explicit cast on num_steps --- Firmware/MotorControl/encoder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/MotorControl/encoder.cpp b/Firmware/MotorControl/encoder.cpp index 6267e152..7bc76d0c 100644 --- a/Firmware/MotorControl/encoder.cpp +++ b/Firmware/MotorControl/encoder.cpp @@ -116,7 +116,7 @@ bool Encoder::run_offset_calibration() { static const float start_lock_duration = 1.0f; static const float scan_omega = 4.0f * M_PI; static const float scan_distance = 16.0f * M_PI; - static const int num_steps = scan_distance / scan_omega * current_meas_hz; + static const int num_steps = scan_distance / scan_omega * (float)current_meas_hz; // Temporarily disable index search so it doesn't mess // with the offset calibration From 94245a608b52412062d5822a62107b9a4772ad7d Mon Sep 17 00:00:00 2001 From: Oskar Weigl Date: Sat, 12 May 2018 22:24:17 -0700 Subject: [PATCH 06/16] explicit cast on num_steps --- Firmware/MotorControl/encoder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/MotorControl/encoder.cpp b/Firmware/MotorControl/encoder.cpp index 7bc76d0c..2c5de455 100644 --- a/Firmware/MotorControl/encoder.cpp +++ b/Firmware/MotorControl/encoder.cpp @@ -116,7 +116,7 @@ bool Encoder::run_offset_calibration() { static const float start_lock_duration = 1.0f; static const float scan_omega = 4.0f * M_PI; static const float scan_distance = 16.0f * M_PI; - static const int num_steps = scan_distance / scan_omega * (float)current_meas_hz; + static const int num_steps = (int)(scan_distance / scan_omega * (float)current_meas_hz); // Temporarily disable index search so it doesn't mess // with the offset calibration From 8b3b1017ba8b223a82dfb12b5df084c61d23f3bf Mon Sep 17 00:00:00 2001 From: Oskar Weigl Date: Sat, 12 May 2018 22:36:44 -0700 Subject: [PATCH 07/16] Update .travis.yml --- .travis.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7260e431..b3639a02 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,17 +13,13 @@ addons: apt: packages: libc6-i386 + arm-none-eabi-gcc cache: directories: - "$HOME/dl" install: -- export GCC_DIR=$HOME/dl/gcc-arm-none-eabi-5_2-2015q4 -- export GCC_ARCHIVE=$HOME/dl/gcc-arm-none-eabi-5_2-2015q4-20151219-linux.tar.bz2 -- export GCC_URL=https://launchpad.net/gcc-arm-embedded/5.0/5-2015-q4-major/+download/gcc-arm-none-eabi-5_2-2015q4-20151219-linux.tar.bz2 -- if [ ! -e $GCC_DIR/bin/arm-none-eabi-gcc ]; then wget $GCC_URL -O $GCC_ARCHIVE; tar xfj $GCC_ARCHIVE -C $HOME/dl; fi -- export PATH=$PATH:$GCC_DIR/bin - export TUP_DIR=$HOME/dl/tup_0.7.5-0~16.04.york0_amd64 - export TUP_ARCHIVE=$HOME/dl/tup_0.7.5-0~16.04.york0_amd64.deb - export TUP_URL=http://ppa.launchpad.net/jonathonf/tup/ubuntu/pool/main/t/tup/tup_0.7.5-0~16.04.york0_amd64.deb From 9b44dc6f81efda816d636f2c4785308b55e43ae4 Mon Sep 17 00:00:00 2001 From: Oskar Weigl Date: Sat, 12 May 2018 22:38:46 -0700 Subject: [PATCH 08/16] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b3639a02..5ac3be5f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ addons: apt: packages: libc6-i386 - arm-none-eabi-gcc + gcc-arm-none-eabi cache: directories: From 37fbcff96d521e4708a7e79e98bfbe63786ce861 Mon Sep 17 00:00:00 2001 From: Oskar Weigl Date: Sat, 12 May 2018 22:39:52 -0700 Subject: [PATCH 09/16] Update .travis.yml --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5ac3be5f..f9146523 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,6 @@ sudo: false addons: apt: packages: - libc6-i386 gcc-arm-none-eabi cache: From 3f720bb374ba13caa92a41ce24926a377a01e56b Mon Sep 17 00:00:00 2001 From: Oskar Weigl Date: Sat, 12 May 2018 23:18:12 -0700 Subject: [PATCH 10/16] Revert "Update .travis.yml" --- .travis.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f9146523..7260e431 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,13 +12,18 @@ sudo: false addons: apt: packages: - gcc-arm-none-eabi + libc6-i386 cache: directories: - "$HOME/dl" install: +- export GCC_DIR=$HOME/dl/gcc-arm-none-eabi-5_2-2015q4 +- export GCC_ARCHIVE=$HOME/dl/gcc-arm-none-eabi-5_2-2015q4-20151219-linux.tar.bz2 +- export GCC_URL=https://launchpad.net/gcc-arm-embedded/5.0/5-2015-q4-major/+download/gcc-arm-none-eabi-5_2-2015q4-20151219-linux.tar.bz2 +- if [ ! -e $GCC_DIR/bin/arm-none-eabi-gcc ]; then wget $GCC_URL -O $GCC_ARCHIVE; tar xfj $GCC_ARCHIVE -C $HOME/dl; fi +- export PATH=$PATH:$GCC_DIR/bin - export TUP_DIR=$HOME/dl/tup_0.7.5-0~16.04.york0_amd64 - export TUP_ARCHIVE=$HOME/dl/tup_0.7.5-0~16.04.york0_amd64.deb - export TUP_URL=http://ppa.launchpad.net/jonathonf/tup/ubuntu/pool/main/t/tup/tup_0.7.5-0~16.04.york0_amd64.deb From dc7af0e9369faf909c12b23331940d6749865263 Mon Sep 17 00:00:00 2001 From: Oskar Weigl Date: Sat, 12 May 2018 23:28:08 -0700 Subject: [PATCH 11/16] update arm gcc to newest install path --- .travis.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7260e431..8391da91 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,11 +19,18 @@ cache: - "$HOME/dl" install: -- export GCC_DIR=$HOME/dl/gcc-arm-none-eabi-5_2-2015q4 -- export GCC_ARCHIVE=$HOME/dl/gcc-arm-none-eabi-5_2-2015q4-20151219-linux.tar.bz2 -- export GCC_URL=https://launchpad.net/gcc-arm-embedded/5.0/5-2015-q4-major/+download/gcc-arm-none-eabi-5_2-2015q4-20151219-linux.tar.bz2 +# - export GCC_DIR=$HOME/dl/gcc-arm-none-eabi-5_2-2015q4 +# - export GCC_ARCHIVE=$HOME/dl/gcc-arm-none-eabi-5_2-2015q4-20151219-linux.tar.bz2 +# - export GCC_URL=https://launchpad.net/gcc-arm-embedded/5.0/5-2015-q4-major/+download/gcc-arm-none-eabi-5_2-2015q4-20151219-linux.tar.bz2 +# - if [ ! -e $GCC_DIR/bin/arm-none-eabi-gcc ]; then wget $GCC_URL -O $GCC_ARCHIVE; tar xfj $GCC_ARCHIVE -C $HOME/dl; fi +# - export PATH=$PATH:$GCC_DIR/bin + +- export GCC_DIR=$HOME/dl/gcc-arm-none-eabi-7-2017-q4-major +- export GCC_ARCHIVE=$HOME/dl/gcc-arm-none-eabi-7-2017-q4-major-linux.tar.bz2 +- export GCC_URL=https://developer.arm.com/-/media/Files/downloads/gnu-rm/7-2017q4/gcc-arm-none-eabi-7-2017-q4-major-linux.tar.bz2 - if [ ! -e $GCC_DIR/bin/arm-none-eabi-gcc ]; then wget $GCC_URL -O $GCC_ARCHIVE; tar xfj $GCC_ARCHIVE -C $HOME/dl; fi - export PATH=$PATH:$GCC_DIR/bin + - export TUP_DIR=$HOME/dl/tup_0.7.5-0~16.04.york0_amd64 - export TUP_ARCHIVE=$HOME/dl/tup_0.7.5-0~16.04.york0_amd64.deb - export TUP_URL=http://ppa.launchpad.net/jonathonf/tup/ubuntu/pool/main/t/tup/tup_0.7.5-0~16.04.york0_amd64.deb From 36b13a3d27d70105eab9897fc6b9b025500a1da7 Mon Sep 17 00:00:00 2001 From: Samuel Sadok Date: Mon, 14 May 2018 13:55:33 -0700 Subject: [PATCH 12/16] fix protocol functions with arguments It invoking functions that take arguments via the protocol was temporarily broken. Such functions were invoked with undefined arguments (usually 0). --- Firmware/communication/protocol.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Firmware/communication/protocol.hpp b/Firmware/communication/protocol.hpp index 87ef82cc..f51fc2de 100644 --- a/Firmware/communication/protocol.hpp +++ b/Firmware/communication/protocol.hpp @@ -812,6 +812,18 @@ public: LOG_PROTO("my tuple is at %x and of size %u\r\n", (uintptr_t)&in_args_, sizeof(in_args_)); } + // The custom copy constructor is needed because otherwise the + // input_properties_ and output_properties_ would point to memory + // locations of the old object. + ProtocolFunction(const ProtocolFunction& other) : + name_(other.name_), obj_(other.obj_), func_ptr_(other.func_ptr_), + input_names_{other.input_names_}, output_names_{other.output_names_}, + input_properties_(PropertyListFactory::template make_property_list<0>(input_names_, in_args_)), + output_properties_(PropertyListFactory::template make_property_list<0>(output_names_, out_args_)) + { + LOG_PROTO("COPIED! my tuple is at %x and of size %u\r\n", (uintptr_t)&in_args_, sizeof(in_args_)); + } + void write_json(size_t id, StreamSink* output) { // write name write_string("{\"name\":\"", output); From 112f4a186496648992583bed0e70e880c5872ec4 Mon Sep 17 00:00:00 2001 From: Samuel Sadok Date: Mon, 14 May 2018 15:19:10 -0700 Subject: [PATCH 13/16] fix undefined variable when enabling ascii protocol --- Firmware/communication/interface_usb.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/Firmware/communication/interface_usb.cpp b/Firmware/communication/interface_usb.cpp index cee94a99..28891a82 100644 --- a/Firmware/communication/interface_usb.cpp +++ b/Firmware/communication/interface_usb.cpp @@ -47,7 +47,6 @@ public: } } usb_packet_output; -#if !defined(USB_PROTOCOL_NATIVE) class TreatPacketSinkAsStreamSink : public StreamSink { public: TreatPacketSinkAsStreamSink(PacketSink& output) : output_(output) {} @@ -66,7 +65,6 @@ public: private: PacketSink& output_; } usb_stream_output(usb_packet_output); -#endif #if defined(USB_PROTOCOL_NATIVE) BidirectionalPacketBasedChannel usb_channel(usb_packet_output); From 62a599bf6ed49f8a27650e61f1a5b653cf9bcc98 Mon Sep 17 00:00:00 2001 From: Samuel Sadok Date: Mon, 14 May 2018 16:13:51 -0700 Subject: [PATCH 14/16] fix ascii protocol compilation --- Firmware/communication/interface_usb.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Firmware/communication/interface_usb.cpp b/Firmware/communication/interface_usb.cpp index 28891a82..b044cdd6 100644 --- a/Firmware/communication/interface_usb.cpp +++ b/Firmware/communication/interface_usb.cpp @@ -2,6 +2,8 @@ #include "interface_usb.h" #include "protocol.hpp" +#include "ascii_protocol.h" + #include #include From 0e32df329fd420793bf8317052de8ccaa41bee90 Mon Sep 17 00:00:00 2001 From: Samuel Sadok Date: Mon, 14 May 2018 16:25:31 -0700 Subject: [PATCH 15/16] fix compilation when using stdout protocol --- Firmware/communication/communication.cpp | 4 ++-- Firmware/communication/interface_uart.cpp | 1 + Firmware/communication/interface_uart.h | 3 +++ Firmware/communication/interface_usb.cpp | 1 + Firmware/communication/interface_usb.h | 3 +++ 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Firmware/communication/communication.cpp b/Firmware/communication/communication.cpp index 1c4accfd..d1a8e487 100644 --- a/Firmware/communication/communication.cpp +++ b/Firmware/communication/communication.cpp @@ -182,10 +182,10 @@ int _write(int file, const char* data, int len); // @brief This is what printf calls internally int _write(int file, const char* data, int len) { #ifdef USB_PROTOCOL_STDOUT - usb_stream_output.process_bytes((const uint8_t *)data, len); + usb_stream_output_ptr->process_bytes((const uint8_t *)data, len); #endif #ifdef UART_PROTOCOL_STDOUT - uart4_stream_output.process_bytes((const uint8_t *)data, len); + uart4_stream_output_ptr->process_bytes((const uint8_t *)data, len); #endif return len; } diff --git a/Firmware/communication/interface_uart.cpp b/Firmware/communication/interface_uart.cpp index 90d976aa..58b4f57d 100644 --- a/Firmware/communication/interface_uart.cpp +++ b/Firmware/communication/interface_uart.cpp @@ -48,6 +48,7 @@ public: private: uint8_t tx_buf_[UART_TX_BUFFER_SIZE]; } uart4_stream_output; +StreamSink* uart4_stream_output_ptr = &uart4_stream_output; PacketToStreamConverter uart4_packet_output(uart4_stream_output); BidirectionalPacketBasedChannel uart4_channel(uart4_packet_output); diff --git a/Firmware/communication/interface_uart.h b/Firmware/communication/interface_uart.h index b5f1ed72..8ad71c19 100644 --- a/Firmware/communication/interface_uart.h +++ b/Firmware/communication/interface_uart.h @@ -2,6 +2,9 @@ #define __INTERFACE_UART_HPP #ifdef __cplusplus +#include "protocol.hpp" +extern StreamSink* uart4_stream_output_ptr; + extern "C" { #endif diff --git a/Firmware/communication/interface_usb.cpp b/Firmware/communication/interface_usb.cpp index b044cdd6..5687e186 100644 --- a/Firmware/communication/interface_usb.cpp +++ b/Firmware/communication/interface_usb.cpp @@ -67,6 +67,7 @@ public: private: PacketSink& output_; } usb_stream_output(usb_packet_output); +StreamSink* usb_stream_output_ptr = &usb_stream_output; #if defined(USB_PROTOCOL_NATIVE) BidirectionalPacketBasedChannel usb_channel(usb_packet_output); diff --git a/Firmware/communication/interface_usb.h b/Firmware/communication/interface_usb.h index a56bca36..9038d822 100644 --- a/Firmware/communication/interface_usb.h +++ b/Firmware/communication/interface_usb.h @@ -2,6 +2,9 @@ #define __INTERFACE_USB_HPP #ifdef __cplusplus +#include "protocol.hpp" +extern StreamSink* usb_stream_output_ptr; + extern "C" { #endif From e0b0824783e996410c9172430d8a6f0727525a13 Mon Sep 17 00:00:00 2001 From: Samuel Sadok Date: Mon, 14 May 2018 16:29:53 -0700 Subject: [PATCH 16/16] add CI jobs for board version 3.5 --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 8391da91..5dd08769 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,6 +43,8 @@ env: - CONFIG_BOARD_VERSION=v3.3 DEPLOY=v3.3 - CONFIG_BOARD_VERSION=v3.4-24V DEPLOY=v3.4-24V - CONFIG_BOARD_VERSION=v3.4-48V DEPLOY=v3.4-48V + - CONFIG_BOARD_VERSION=v3.5-24V DEPLOY=v3.5-24V + - CONFIG_BOARD_VERSION=v3.5-48V DEPLOY=v3.5-48V # Various protocol combinations - CONFIG_BOARD_VERSION=v3.4-24V CONFIG_USB_PROTOCOL=native-stream CONFIG_UART_PROTOCOL=native