diff --git a/.travis.yml b/.travis.yml index 7260e431..5dd08769 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 @@ -36,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 diff --git a/Firmware/MotorControl/encoder.cpp b/Firmware/MotorControl/encoder.cpp index 289f97f1..f80f04dc 100644 --- a/Firmware/MotorControl/encoder.cpp +++ b/Firmware/MotorControl/encoder.cpp @@ -130,7 +130,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 = (int)(scan_distance / scan_omega * (float)current_meas_hz); // Temporarily disable index search so it doesn't mess // with the offset calibration diff --git a/Firmware/build.lua b/Firmware/build.lua index 8ef67627..ea792219 100644 --- a/Firmware/build.lua +++ b/Firmware/build.lua @@ -49,7 +49,12 @@ end function GCCToolchain(prefix, builddir, compiler_flags, linker_flags) -- add some default compiler flags - 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 @@ -79,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 diff --git a/Firmware/communication/communication.cpp b/Firmware/communication/communication.cpp index 46fb4263..97e13ce3 100644 --- a/Firmware/communication/communication.cpp +++ b/Firmware/communication/communication.cpp @@ -147,7 +147,7 @@ static inline auto make_obj_tree() { 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"), -#if HW_VERSION_MAJOR == 3 && HW_VERSION_MINOR == 4 +#if HW_VERSION_MAJOR == 3 && HW_VERSION_MINOR >= 3 make_protocol_property("adc_gpio1", &adc_measurements_[0]), make_protocol_property("adc_gpio2", &adc_measurements_[1]), #endif @@ -197,10 +197,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 cee94a99..5687e186 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 @@ -47,7 +49,6 @@ public: } } usb_packet_output; -#if !defined(USB_PROTOCOL_NATIVE) class TreatPacketSinkAsStreamSink : public StreamSink { public: TreatPacketSinkAsStreamSink(PacketSink& output) : output_(output) {} @@ -66,7 +67,7 @@ public: private: PacketSink& output_; } usb_stream_output(usb_packet_output); -#endif +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 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); 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