From 43c65b3e3c2ccccb456b1a8670b237e45bb61301 Mon Sep 17 00:00:00 2001 From: ckormanyos Date: Sat, 23 Nov 2024 04:35:39 +0100 Subject: [PATCH 1/8] Try repairing CI --- .github/workflows/wide_integer.yml | 42 +++++++++++++++++++----------- test/stopwatch.h | 4 ++- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/.github/workflows/wide_integer.yml b/.github/workflows/wide_integer.yml index 0800e1e..eb84ac7 100644 --- a/.github/workflows/wide_integer.yml +++ b/.github/workflows/wide_integer.yml @@ -605,7 +605,7 @@ jobs: - name: wide-integer-run run: bash -l -c 'cd $(cygpath -u "$GITHUB_WORKSPACE") && ./wide_integer.exe' gcc-arm-none-eabi: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest defaults: run: shell: bash @@ -620,12 +620,12 @@ jobs: fetch-depth: '0' - name: update-tools run: | - sudo apt install libncurses5 libpython2.7 + sudo apt install libncursesw5 mkdir -p emu_env && cd emu_env - wget --no-check-certificate https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2 - tar -xf gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2 - wget --no-check-certificate https://github.com/xpack-dev-tools/qemu-arm-xpack/releases/download/v7.1.0-1/xpack-qemu-arm-7.1.0-1-linux-x64.tar.gz - tar -xzf xpack-qemu-arm-7.1.0-1-linux-x64.tar.gz + wget --no-check-certificate https://developer.arm.com/-/media/Files/downloads/gnu/13.3.rel1/binrel/arm-gnu-toolchain-13.3.rel1-x86_64-arm-none-eabi.tar.xz + tar -xf arm-gnu-toolchain-13.3.rel1-x86_64-arm-none-eabi.tar.xz + wget --no-check-certificate https://github.com/xpack-dev-tools/qemu-arm-xpack/releases/download/v8.2.6-1/xpack-qemu-arm-8.2.6-1-linux-x64.tar.gz + tar -xzf xpack-qemu-arm-8.2.6-1-linux-x64.tar.gz working-directory: ./ - id: upcase_my_example uses: ASzc/change-string-case-action@v6 @@ -633,21 +633,33 @@ jobs: string: ${{ matrix.example }} - name: build-example-stm32f429 run: | + PATH="${{ runner.workspace }}/wide_integer/emu_env/arm-gnu-toolchain-13.3.rel1-x86_64-arm-none-eabi/bin:$PATH" + echo 'Query arm-none-eabi-g++ version' + echo + arm-none-eabi-g++ -v + echo mkdir -p bin - emu_env/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-g++ -std=${{ matrix.standard }} -Wall -Wextra -Wpedantic -pedantic -O0 -g -gdwarf-2 -ffunction-sections -fdata-sections -x c++ -fno-rtti -fno-use-cxa-atexit -fno-exceptions -fno-nonansi-builtins -fno-threadsafe-statics -fno-enforce-eh-specs -ftemplate-depth=32 -mcpu=cortex-m4 -mtune=cortex-m4 -mthumb -mfloat-abi=soft -mno-unaligned-access -mno-long-calls -I. -DWIDE_INTEGER_DISABLE_IOSTREAM -DWIDE_INTEGER_DISABLE_TO_STRING -DWIDE_INTEGER_DISABLE_TRIVIAL_COPY_AND_STD_LAYOUT_CHECKS -DWIDE_INTEGER_NAMESPACE=ckormanyos -DWIDE_INTEGER_STANDALONE_${{ steps.upcase_my_example.outputs.uppercase }} examples/${{ matrix.example }}.cpp ./target/micros/stm32f429/make/single/crt.cpp -nostartfiles -Wl,--gc-sections -Wl,-Map,./bin/${{ matrix.example }}.map -T ./target/micros/stm32f429/make/stm32f429.ld --specs=nano.specs --specs=nosys.specs -o ./bin/${{ matrix.example }}.elf - emu_env/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-objcopy ./bin/${{ matrix.example }}.elf -O ihex ./bin/${{ matrix.example }}.hex + arm-none-eabi-g++ -std=${{ matrix.standard }} -Werror -Wall -Wextra -Wpedantic -Wpedantic -Wconversion -Wsign-conversion -O1 -g -gdwarf-2 -ffunction-sections -fdata-sections -x c++ -fno-rtti -fno-use-cxa-atexit -fno-exceptions -fno-nonansi-builtins -fno-threadsafe-statics -fno-enforce-eh-specs -ftemplate-depth=32 -mcpu=cortex-m4 -mtune=cortex-m4 -mthumb -mfloat-abi=soft -mno-unaligned-access -mno-long-calls -I. -DWIDE_INTEGER_DISABLE_IOSTREAM -DWIDE_INTEGER_DISABLE_TO_STRING -DWIDE_INTEGER_DISABLE_TRIVIAL_COPY_AND_STD_LAYOUT_CHECKS -DWIDE_INTEGER_NAMESPACE=ckormanyos -DWIDE_INTEGER_STANDALONE_${{ steps.upcase_my_example.outputs.uppercase }} examples/${{ matrix.example }}.cpp ./target/micros/stm32f429/make/single/crt.cpp -nostartfiles -Wl,--gc-sections -Wl,-Map,./bin/${{ matrix.example }}.map -T ./target/micros/stm32f429/make/stm32f429.ld --specs=nano.specs --specs=nosys.specs -o ./bin/${{ matrix.example }}.elf + arm-none-eabi-objcopy ./bin/${{ matrix.example }}.elf -O ihex ./bin/${{ matrix.example }}.hex ls -la ./bin/${{ matrix.example }}.elf ./bin/${{ matrix.example }}.hex ./bin/${{ matrix.example }}.map working-directory: ./ - name: emulate-target stm32f429 run: | - ./emu_env/xpack-qemu-arm-7.1.0-1/bin/qemu-system-gnuarmeclipse --verbose --mcu STM32F429ZI --nographic --gdb tcp::9999 -d unimp,guest_errors & + PATH="${{ runner.workspace }}/wide_integer/emu_env/xpack-qemu-arm-8.2.6-1/bin:$PATH" + qemu-system-gnuarmeclipse --verbose --mcu STM32F429ZI --nographic --gdb tcp::9999 -d unimp,guest_errors & + sleep 2 working-directory: ./ - name: run-test-on-target run: | - ./emu_env/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gdb-py ./bin/${{ matrix.example }}.elf -x ./target/build/test_examples_emulator.py - qemu_result=$? - echo "qemu_result" "$qemu_result" - echo "qemu_result" "$qemu_result" | grep 'qemu_result 0' + sleep 2 + PATH="${{ runner.workspace }}/wide_integer/emu_env/arm-gnu-toolchain-13.3.rel1-x86_64-arm-none-eabi/bin:$PATH" + echo 'Run test on target' + echo + arm-none-eabi-gdb ./bin/${{ matrix.example }}.elf -x ./target/build/test_app_benchmarks_emulator.gdb > ./${{ matrix.example }}.txt + cat ./${{ matrix.example }}.txt + echo + echo 'We will now grep for the right answer...' + grep 'value 0xF00DCAFE' ./${{ matrix.example }}.txt working-directory: ./ gcc-avr: runs-on: ubuntu-latest @@ -678,8 +690,8 @@ jobs: mkdir bin echo ${{ steps.upcase_my_example.outputs.uppercase }} echo 'compile examples/${{ matrix.example }}.cpp with:' - echo 'avr-g++ -x c++ -std=${{ matrix.standard }} -Os -Werror -Wall -Wextra -Wpedantic -pedantic -Wmain -Wundef -Wconversion -Wsign-conversion -Wunused-parameter -Wuninitialized -Wmissing-declarations -Wshadow -Wunreachable-code -Wswitch-default -Wswitch-enum -Wcast-align -Wmissing-include-dirs -Winit-self -Wfloat-equal -Wdouble-promotion -mmcu=atmega328p -mrelax -finline-functions -finline-limit=32 -fsigned-char -g -gdwarf-2 -fno-exceptions -ffunction-sections -fdata-sections -fno-rtti -fno-use-cxa-atexit -fno-exceptions -fno-threadsafe-statics -fno-enforce-eh-specs -ftemplate-depth=32 -Wzero-as-null-pointer-constant -I. -I../real-time-cpp-root/ref_app/src -I../real-time-cpp-root/ref_app/src/util/STL -DWIDE_INTEGER_DISABLE_IOSTREAM -DWIDE_INTEGER_DISABLE_TO_STRING -DWIDE_INTEGER_DISABLE_TRIVIAL_COPY_AND_STD_LAYOUT_CHECKS -DWIDE_INTEGER_DISABLE_IMPLEMENT_UTIL_DYNAMIC_ARRAY -DWIDE_INTEGER_NAMESPACE=ckormanyos -DWIDE_INTEGER_STANDALONE_${{ steps.upcase_my_example.outputs.uppercase }} examples/${{ matrix.example }}.cpp -Wl,--gc-sections -Wl,-Map,./bin/${{ matrix.example }}.map -o bin/${{ matrix.example }}.elf' - avr-g++ -x c++ -std=${{ matrix.standard }} -Os -Werror -Wall -Wextra -Wpedantic -pedantic -Wmain -Wundef -Wconversion -Wsign-conversion -Wunused-parameter -Wuninitialized -Wmissing-declarations -Wshadow -Wunreachable-code -Wswitch-default -Wswitch-enum -Wcast-align -Wmissing-include-dirs -Winit-self -Wfloat-equal -Wdouble-promotion -mmcu=atmega328p -mrelax -finline-functions -finline-limit=32 -fsigned-char -g -gdwarf-2 -fno-exceptions -ffunction-sections -fdata-sections -fno-rtti -fno-use-cxa-atexit -fno-exceptions -fno-threadsafe-statics -fno-enforce-eh-specs -ftemplate-depth=32 -Wzero-as-null-pointer-constant -I. -I../real-time-cpp-root/ref_app/src -I../real-time-cpp-root/ref_app/src/util/STL -DWIDE_INTEGER_DISABLE_IOSTREAM -DWIDE_INTEGER_DISABLE_TO_STRING -DWIDE_INTEGER_DISABLE_TRIVIAL_COPY_AND_STD_LAYOUT_CHECKS -DWIDE_INTEGER_DISABLE_IMPLEMENT_UTIL_DYNAMIC_ARRAY -DWIDE_INTEGER_NAMESPACE=ckormanyos -DWIDE_INTEGER_STANDALONE_${{ steps.upcase_my_example.outputs.uppercase }} examples/${{ matrix.example }}.cpp -Wl,--gc-sections -Wl,-Map,./bin/${{ matrix.example }}.map -o bin/${{ matrix.example }}.elf + echo 'avr-g++ -x c++ -std=${{ matrix.standard }} -Os -Werror -Wall -Wextra -Wpedantic -Wpedantic -Wmain -Wundef -Wconversion -Wsign-conversion -Wunused-parameter -Wuninitialized -Wmissing-declarations -Wshadow -Wunreachable-code -Wswitch-default -Wswitch-enum -Wcast-align -Wmissing-include-dirs -Winit-self -Wfloat-equal -Wdouble-promotion -mmcu=atmega328p -mrelax -finline-functions -finline-limit=32 -fsigned-char -g -gdwarf-2 -fno-exceptions -ffunction-sections -fdata-sections -fno-rtti -fno-use-cxa-atexit -fno-exceptions -fno-threadsafe-statics -fno-enforce-eh-specs -ftemplate-depth=32 -Wzero-as-null-pointer-constant -I. -I../real-time-cpp-root/ref_app/src -I../real-time-cpp-root/ref_app/src/util/STL -DWIDE_INTEGER_DISABLE_IOSTREAM -DWIDE_INTEGER_DISABLE_TO_STRING -DWIDE_INTEGER_DISABLE_TRIVIAL_COPY_AND_STD_LAYOUT_CHECKS -DWIDE_INTEGER_DISABLE_IMPLEMENT_UTIL_DYNAMIC_ARRAY -DWIDE_INTEGER_NAMESPACE=ckormanyos -DWIDE_INTEGER_STANDALONE_${{ steps.upcase_my_example.outputs.uppercase }} examples/${{ matrix.example }}.cpp -Wl,--gc-sections -Wl,-Map,./bin/${{ matrix.example }}.map -o bin/${{ matrix.example }}.elf' + avr-g++ -x c++ -std=${{ matrix.standard }} -Os -Werror -Wall -Wextra -Wpedantic -Wpedantic -Wmain -Wundef -Wconversion -Wsign-conversion -Wunused-parameter -Wuninitialized -Wmissing-declarations -Wshadow -Wunreachable-code -Wswitch-default -Wswitch-enum -Wcast-align -Wmissing-include-dirs -Winit-self -Wfloat-equal -Wdouble-promotion -mmcu=atmega328p -mrelax -finline-functions -finline-limit=32 -fsigned-char -g -gdwarf-2 -fno-exceptions -ffunction-sections -fdata-sections -fno-rtti -fno-use-cxa-atexit -fno-exceptions -fno-threadsafe-statics -fno-enforce-eh-specs -ftemplate-depth=32 -Wzero-as-null-pointer-constant -I. -I../real-time-cpp-root/ref_app/src -I../real-time-cpp-root/ref_app/src/util/STL -DWIDE_INTEGER_DISABLE_IOSTREAM -DWIDE_INTEGER_DISABLE_TO_STRING -DWIDE_INTEGER_DISABLE_TRIVIAL_COPY_AND_STD_LAYOUT_CHECKS -DWIDE_INTEGER_DISABLE_IMPLEMENT_UTIL_DYNAMIC_ARRAY -DWIDE_INTEGER_NAMESPACE=ckormanyos -DWIDE_INTEGER_STANDALONE_${{ steps.upcase_my_example.outputs.uppercase }} examples/${{ matrix.example }}.cpp -Wl,--gc-sections -Wl,-Map,./bin/${{ matrix.example }}.map -o bin/${{ matrix.example }}.elf echo echo 'run objcopy with:' echo 'avr-objcopy bin/${{ matrix.example }}.elf -O ihex bin/${{ matrix.example }}.hex' diff --git a/test/stopwatch.h b/test/stopwatch.h index e1ab5ec..f3f0bb0 100644 --- a/test/stopwatch.h +++ b/test/stopwatch.h @@ -61,7 +61,9 @@ timespec ts { }; - timespec_get(&ts, TIME_UTC); + const int ntsp { timespec_get(&ts, TIME_UTC) }; + + static_cast(ntsp); return static_cast From bbf62fbd9ed0bafd9a5b716f210d5357a6339d36 Mon Sep 17 00:00:00 2001 From: ckormanyos Date: Sat, 23 Nov 2024 04:47:55 +0100 Subject: [PATCH 2/8] Repair CI typos --- .github/workflows/wide_integer.yml | 8 +- target/build/test_examples_emulator.gdb | 29 ++++++ target/build/test_examples_emulator.py | 131 ------------------------ wide_integer_vs2022.vcxproj | 2 +- wide_integer_vs2022.vcxproj.filters | 2 +- 5 files changed, 35 insertions(+), 137 deletions(-) create mode 100644 target/build/test_examples_emulator.gdb delete mode 100644 target/build/test_examples_emulator.py diff --git a/.github/workflows/wide_integer.yml b/.github/workflows/wide_integer.yml index eb84ac7..38d5dda 100644 --- a/.github/workflows/wide_integer.yml +++ b/.github/workflows/wide_integer.yml @@ -633,7 +633,7 @@ jobs: string: ${{ matrix.example }} - name: build-example-stm32f429 run: | - PATH="${{ runner.workspace }}/wide_integer/emu_env/arm-gnu-toolchain-13.3.rel1-x86_64-arm-none-eabi/bin:$PATH" + PATH="${{ runner.workspace }}/wide-integer/emu_env/arm-gnu-toolchain-13.3.rel1-x86_64-arm-none-eabi/bin:$PATH" echo 'Query arm-none-eabi-g++ version' echo arm-none-eabi-g++ -v @@ -645,17 +645,17 @@ jobs: working-directory: ./ - name: emulate-target stm32f429 run: | - PATH="${{ runner.workspace }}/wide_integer/emu_env/xpack-qemu-arm-8.2.6-1/bin:$PATH" + PATH="${{ runner.workspace }}/wide-integer/emu_env/xpack-qemu-arm-8.2.6-1/bin:$PATH" qemu-system-gnuarmeclipse --verbose --mcu STM32F429ZI --nographic --gdb tcp::9999 -d unimp,guest_errors & sleep 2 working-directory: ./ - name: run-test-on-target run: | sleep 2 - PATH="${{ runner.workspace }}/wide_integer/emu_env/arm-gnu-toolchain-13.3.rel1-x86_64-arm-none-eabi/bin:$PATH" + PATH="${{ runner.workspace }}/wide-integer/emu_env/arm-gnu-toolchain-13.3.rel1-x86_64-arm-none-eabi/bin:$PATH" echo 'Run test on target' echo - arm-none-eabi-gdb ./bin/${{ matrix.example }}.elf -x ./target/build/test_app_benchmarks_emulator.gdb > ./${{ matrix.example }}.txt + arm-none-eabi-gdb ./bin/${{ matrix.example }}.elf -x ./target/build/test_examples_emulator.gdb > ./${{ matrix.example }}.txt cat ./${{ matrix.example }}.txt echo echo 'We will now grep for the right answer...' diff --git a/target/build/test_examples_emulator.gdb b/target/build/test_examples_emulator.gdb new file mode 100644 index 0000000..d013899 --- /dev/null +++ b/target/build/test_examples_emulator.gdb @@ -0,0 +1,29 @@ +#/////////////////////////////////////////////////////////////////// +#// Copyright Christopher Kormanyos 2020 - 2024. // +#// Distributed under the Boost Software License, // +#// Version 1.0. (See accompanying file LICENSE_1_0.txt // +#// or copy at http://www.boost.org/LICENSE_1_0.txt) // +#/////////////////////////////////////////////////////////////////// + + +# Connect to the target (e.g., OpenOCD or another GDB server). +target remote localhost:9999 +monitor halt + +# Ensure that the program is loaded. +load + +# Set a breakpoint at the specified subroutine. +break app_benchmark_get_standalone_result + +# Start or continue program execution. +continue + +# Format and print the value of a variable. +printf "value 0x%X\n\n", app_benchmark_standalone_result + +# Delete (all) breakpoint(s). +delete + +# Perform a non-elegant quit of the GDB session. +quit diff --git a/target/build/test_examples_emulator.py b/target/build/test_examples_emulator.py deleted file mode 100644 index c179b7d..0000000 --- a/target/build/test_examples_emulator.py +++ /dev/null @@ -1,131 +0,0 @@ -#------------------------------------------------------------------------------- -# Name: test_examples_emulator.py -# Purpose: -# -# Author: Christopher Kormanyos -# -# Created: 02/04/2021 -# -# Copyright: Copyright Christopher Kormanyos 2007 - 2024 -# -# Licence: Distributed under the Boost Software License, -# Version 1.0. (See accompanying file LICENSE_1_0.txt -# or copy at http://www.boost.org/LICENSE_1_0.txt) -#------------------------------------------------------------------------------- - -#!/usr/bin/env python2 - -# import python packages -import gdb -import time -import logging -import sys - -#------------------------------------------------------------------------------- -# --- class: qemu_emulator -#------------------------------------------------------------------------------- -class qemu_emulator: - def __init__(self, tcp_port, iterations): - self.tcp_port = tcp_port - self.iterations = iterations - - # qemu initialization - def initialize(self): - self.connect_to_server(self.tcp_port) - self.create_log_file() - self.load_elf() - - # Excute gdb commands - def execute(self, command, from_tty = False, to_string = False): - gdb.execute('{}'.format(command), from_tty, to_string) - - # Create log file - def create_log_file(self): - logging.basicConfig(filename='emu-target.log',level=logging.DEBUG, filemode='w') - logging.info('------- Running GDB Test -----') - - # Connect to server - def connect_to_server(self, tcp_port): - self.execute('target remote localhost:{}'.format(tcp_port)) - self.execute('monitor reset') - self.execute('set confirm off') - - # Load object data base - def load_elf(self): - self.execute('load') - - # Run the benchmark - def run(self): - self.execute('continue') - - def next(self): - self.execute('next') - - # Set gdb Bp - def set_gdb_break_point(self): - my_bp = gdb.Breakpoint('example_get_standalone_result') - return my_bp - - # Delete gdb Bp - def delete_gdb_break_point(self, bp): - bp.delete() - - # Get gdb result - def get_gdb_result(self): - my_result = gdb.parse_and_eval("example_standalone_result") - return my_result - - # Convert from gdb type to hex - def convert_to_hex(self, gdb_value): - val_as_str = str(gdb_value) - val_as_hex = hex(int(val_as_str)) - return val_as_hex - - # Check the gdb return value - def check_gdb_result(self, result_as_hex): - if result_as_hex == "0xf00dcafe": - return True - else: - return False - -#------------------------------------------------------------------------------- -# --- GDB Script starts here -# See also https://embeddedartistry.com/blog/2020/11/09/metal-gdb-controlling-gdb-through-python-scripts-with-the-gdb-python-api/ -#------------------------------------------------------------------------------- - -# Script Config -tcp_port = 9999 -iterations = 64 - -# Create a qemu object -obj = qemu_emulator(tcp_port, iterations) - -# Initialize -obj.initialize() - -# Set break point -bp1 = obj.set_gdb_break_point() - -# Run the benchmark -obj.run() - -# Get gdb result -my_value = obj.get_gdb_result() -time.sleep(0.5) - -# Delete break point -obj.delete_gdb_break_point(bp1) - -# Convert gdb result to hex -value_as_hex = obj.convert_to_hex(my_value) - -# Print the return value -print("Result value as hex: " + value_as_hex) - -# Check the gdb result and quit -result_is_ok = obj.check_gdb_result(value_as_hex) - -if result_is_ok == True: - sys.exit(0) -else: - sys.exit(-1) diff --git a/wide_integer_vs2022.vcxproj b/wide_integer_vs2022.vcxproj index 7155af6..9dbb0d3 100644 --- a/wide_integer_vs2022.vcxproj +++ b/wide_integer_vs2022.vcxproj @@ -320,7 +320,7 @@ - + true true true diff --git a/wide_integer_vs2022.vcxproj.filters b/wide_integer_vs2022.vcxproj.filters index b146d99..e19e8b8 100644 --- a/wide_integer_vs2022.vcxproj.filters +++ b/wide_integer_vs2022.vcxproj.filters @@ -287,7 +287,7 @@ .github\workflows - + target\build From d53725498f02f83f25bc7db03dcdac07e3b81cd4 Mon Sep 17 00:00:00 2001 From: ckormanyos Date: Sat, 23 Nov 2024 07:07:11 +0100 Subject: [PATCH 3/8] Handle warnings in crt-init --- target/micros/stm32f429/make/single/crt.cpp | 31 +++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/target/micros/stm32f429/make/single/crt.cpp b/target/micros/stm32f429/make/single/crt.cpp index 25fb11a..e2753da 100644 --- a/target/micros/stm32f429/make/single/crt.cpp +++ b/target/micros/stm32f429/make/single/crt.cpp @@ -1,3 +1,17 @@ +/////////////////////////////////////////////////////////////////////////////// +// Copyright Christopher Kormanyos 2018 - 2024. +// Distributed under the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Warray-bounds" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow=" +#endif + #include #include #include @@ -5,6 +19,11 @@ #include #include +// STM32 EABI ARM(R) Cortex-M4(TM) startup code. +// Expressed with C++ for STM32Fx by Chris. + +// C:\Users\User\Documents\Ks\uC_Software\Boards\real-time-cpp\ref_app\tools\Util\MinGW\msys\1.0\local\gcc-9.3.1-arm-none-eabi\bin\arm-none-eabi-g++ -std=c++14 -Wall -Wextra -pedantic -O2 -g -gdwarf-2 -fno-exceptions -ffunction-sections -fdata-sections -x c++ -fno-rtti -fno-use-cxa-atexit -fno-exceptions -fno-nonansi-builtins -fno-threadsafe-statics -fno-enforce-eh-specs -ftemplate-depth=32 -mcpu=cortex-m4 -mtune=cortex-m4 -mthumb -mfloat-abi=soft -mno-unaligned-access -mno-long-calls -I./src/mcal/stm32f446 -I./src -DAPP_BENCHMARK_TYPE=APP_BENCHMARK_TYPE_CRC -DAPP_BENCHMARK_STANDALONE_MAIN ./src/app/benchmark/app_benchmark_crc.cpp ./target/micros/stm32f446/make/single/crt.cpp -nostartfiles -Wl,--gc-sections -Wl,-Map,./bin/app_benchmark_crc.map -T ./target/micros/stm32f446/make/stm32f446.ld -o ./bin/app_benchmark_crc.elf + namespace crt { void init_ram(); @@ -24,7 +43,8 @@ void __my_startup(void) // the base position of the interrupt vector table. // So we do nothing here. - // TBD: Chip init: Watchdog, port, and oscillator, if any needed. + // Note: Not needed: + // Chip init: Watchdog, port, and oscillator, if any needed. // Initialize statics from ROM to RAM. // Zero-clear default-initialized static RAM. @@ -37,9 +57,7 @@ void __my_startup(void) asm volatile("ldr r3, =main"); asm volatile("blx r3"); - exit(EXIT_SUCCESS); - - // TBD: Nothing on return from main. + // Do nothing on return from main. } extern "C" void _exit (int); @@ -111,7 +129,6 @@ extern "C" void __svc_handler () __attribute__((used, noinline)); extern "C" void __debug_mon_handler () __attribute__((used, noinline)); extern "C" void __pend_sv_handler () __attribute__((used, noinline)); extern "C" void __sys_tick_handler () __attribute__((used, noinline)); -extern "C" void __vector_timer4 (); extern "C" void __vector_unused_irq () { for(;;) { ; } } extern "C" void __nmi_handler () { for(;;) { ; } } @@ -267,3 +284,7 @@ const volatile std::array __isr_vector = nullptr // 0x01FC, dummy }}; +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#pragma GCC diagnostic pop +#endif \ No newline at end of file From 2989e44f77a17fe2060a1385d890ef329cfc4329 Mon Sep 17 00:00:00 2001 From: ckormanyos Date: Sat, 23 Nov 2024 07:13:40 +0100 Subject: [PATCH 4/8] Correct minor CI errors --- .github/workflows/CodeQL.yml | 6 +----- target/build/test_examples_emulator.gdb | 9 +-------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/.github/workflows/CodeQL.yml b/.github/workflows/CodeQL.yml index 0a7691e..a1cc6ae 100644 --- a/.github/workflows/CodeQL.yml +++ b/.github/workflows/CodeQL.yml @@ -23,7 +23,7 @@ jobs: strategy: fail-fast: false matrix: - language: [ python, cpp ] + language: [ cpp ] steps: - name: Checkout @@ -49,10 +49,6 @@ jobs: languages: ${{ matrix.language }} queries: +security-and-quality - - name: Autobuild - uses: github/codeql-action/autobuild@v3 - if: ${{ matrix.language == 'python' }} - - name: Build cpp if: ${{ matrix.language == 'cpp' }} run: | diff --git a/target/build/test_examples_emulator.gdb b/target/build/test_examples_emulator.gdb index d013899..4abe88d 100644 --- a/target/build/test_examples_emulator.gdb +++ b/target/build/test_examples_emulator.gdb @@ -1,11 +1,4 @@ -#/////////////////////////////////////////////////////////////////// -#// Copyright Christopher Kormanyos 2020 - 2024. // -#// Distributed under the Boost Software License, // -#// Version 1.0. (See accompanying file LICENSE_1_0.txt // -#// or copy at http://www.boost.org/LICENSE_1_0.txt) // -#/////////////////////////////////////////////////////////////////// - - + # Connect to the target (e.g., OpenOCD or another GDB server). target remote localhost:9999 monitor halt From 9af4d632941fbbac2cb7259d4d9cdcb9de19d40f Mon Sep 17 00:00:00 2001 From: ckormanyos Date: Sat, 23 Nov 2024 08:14:14 +0100 Subject: [PATCH 5/8] Handle UNIX line endings --- target/build/test_examples_emulator.gdb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/build/test_examples_emulator.gdb b/target/build/test_examples_emulator.gdb index 4abe88d..b67174f 100644 --- a/target/build/test_examples_emulator.gdb +++ b/target/build/test_examples_emulator.gdb @@ -1,4 +1,4 @@ - + # Connect to the target (e.g., OpenOCD or another GDB server). target remote localhost:9999 monitor halt From d69c97dedf5e33ee556b57bfcaab1a9b96194152 Mon Sep 17 00:00:00 2001 From: ckormanyos Date: Sat, 23 Nov 2024 08:20:03 +0100 Subject: [PATCH 6/8] Repair type in GDB Debug session --- examples/example001_mul_div.cpp | 5 +---- target/build/test_examples_emulator.gdb | 8 +++++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/examples/example001_mul_div.cpp b/examples/example001_mul_div.cpp index 9733578..0763133 100644 --- a/examples/example001_mul_div.cpp +++ b/examples/example001_mul_div.cpp @@ -99,10 +99,7 @@ extern "C" auto example_get_standalone_result(void) -> bool { - volatile auto result_is_ok = - (example_standalone_result == static_cast(UINT32_C(0xF00DCAFE))); - - return result_is_ok; + return { example_standalone_result == static_cast(UINT32_C(0xF00DCAFE)) }; } } diff --git a/target/build/test_examples_emulator.gdb b/target/build/test_examples_emulator.gdb index b67174f..55418cc 100644 --- a/target/build/test_examples_emulator.gdb +++ b/target/build/test_examples_emulator.gdb @@ -1,3 +1,9 @@ +# /////////////////////////////////////////////////////////////////// +# // Copyright Christopher Kormanyos 2020 - 2024. // +# // Distributed under the Boost Software License, // +# // Version 1.0. (See accompanying file LICENSE_1_0.txt // +# // or copy at http://www.boost.org/LICENSE_1_0.txt) // +# /////////////////////////////////////////////////////////////////// # Connect to the target (e.g., OpenOCD or another GDB server). target remote localhost:9999 @@ -13,7 +19,7 @@ break app_benchmark_get_standalone_result continue # Format and print the value of a variable. -printf "value 0x%X\n\n", app_benchmark_standalone_result +printf "value 0x%X\n\n", example_get_standalone_result # Delete (all) breakpoint(s). delete From ca75dc5cc71f931c4381856568d46fa7f2e7a5e2 Mon Sep 17 00:00:00 2001 From: ckormanyos Date: Sat, 23 Nov 2024 08:51:48 +0100 Subject: [PATCH 7/8] Repair typos in GDB script --- target/build/test_examples_emulator.gdb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/build/test_examples_emulator.gdb b/target/build/test_examples_emulator.gdb index 55418cc..8ce3b7e 100644 --- a/target/build/test_examples_emulator.gdb +++ b/target/build/test_examples_emulator.gdb @@ -13,13 +13,13 @@ monitor halt load # Set a breakpoint at the specified subroutine. -break app_benchmark_get_standalone_result +break example_get_standalone_result # Start or continue program execution. continue # Format and print the value of a variable. -printf "value 0x%X\n\n", example_get_standalone_result +printf "value 0x%X\n\n", example_standalone_result # Delete (all) breakpoint(s). delete From 9dadc57dcc3c6b203772b60d5e82bc7202f28ac4 Mon Sep 17 00:00:00 2001 From: ckormanyos Date: Sat, 23 Nov 2024 09:04:08 +0100 Subject: [PATCH 8/8] Prettier syntax and comments --- examples/example001_mul_div.cpp | 10 +++++----- examples/example003_sqrt.cpp | 15 ++++++--------- target/build/test_examples_emulator.gdb | 10 +++++----- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/examples/example001_mul_div.cpp b/examples/example001_mul_div.cpp index 0763133..a254ba8 100644 --- a/examples/example001_mul_div.cpp +++ b/examples/example001_mul_div.cpp @@ -68,10 +68,10 @@ extern "C" { extern volatile std::uint32_t example_standalone_result; - auto example_run_standalone (void) -> bool; - auto example_get_standalone_result(void) -> bool; + auto example_run_standalone () -> bool; + auto example_get_standalone_result() noexcept -> bool; - auto example_run_standalone(void) -> bool + auto example_run_standalone() -> bool { bool result_is_ok = true; @@ -97,7 +97,7 @@ extern "C" return result_is_ok; } - auto example_get_standalone_result(void) -> bool + auto example_get_standalone_result() noexcept -> bool { return { example_standalone_result == static_cast(UINT32_C(0xF00DCAFE)) }; } @@ -115,7 +115,7 @@ auto main() -> int extern "C" { - volatile std::uint32_t example_standalone_result; + volatile std::uint32_t example_standalone_result { }; } #endif diff --git a/examples/example003_sqrt.cpp b/examples/example003_sqrt.cpp index 016b843..9b9aaeb 100644 --- a/examples/example003_sqrt.cpp +++ b/examples/example003_sqrt.cpp @@ -56,10 +56,10 @@ extern "C" { extern volatile std::uint32_t example_standalone_result; - auto example_run_standalone (void) -> bool; - auto example_get_standalone_result(void) -> bool; + auto example_run_standalone () -> bool; + auto example_get_standalone_result() noexcept -> bool; - auto example_run_standalone(void) -> bool + auto example_run_standalone() -> bool { bool result_is_ok = true; @@ -85,12 +85,9 @@ extern "C" return result_is_ok; } - auto example_get_standalone_result(void) -> bool + auto example_get_standalone_result() noexcept -> bool { - volatile auto result_is_ok = - (example_standalone_result == static_cast(UINT32_C(0xF00DCAFE))); - - return result_is_ok; + return { example_standalone_result == static_cast(UINT32_C(0xF00DCAFE)) }; } } @@ -106,7 +103,7 @@ auto main() -> int extern "C" { - volatile std::uint32_t example_standalone_result; + volatile std::uint32_t example_standalone_result { }; } #endif diff --git a/target/build/test_examples_emulator.gdb b/target/build/test_examples_emulator.gdb index 8ce3b7e..d045b6b 100644 --- a/target/build/test_examples_emulator.gdb +++ b/target/build/test_examples_emulator.gdb @@ -1,9 +1,9 @@ # /////////////////////////////////////////////////////////////////// -# // Copyright Christopher Kormanyos 2020 - 2024. // -# // Distributed under the Boost Software License, // -# // Version 1.0. (See accompanying file LICENSE_1_0.txt // -# // or copy at http://www.boost.org/LICENSE_1_0.txt) // -# /////////////////////////////////////////////////////////////////// +# // Copyright Christopher Kormanyos 2020 - 2024. +# // Distributed under the Boost Software License, +# // Version 1.0. (See accompanying file LICENSE_1_0.txt +# // or copy at http://www.boost.org/LICENSE_1_0.txt) +# // # Connect to the target (e.g., OpenOCD or another GDB server). target remote localhost:9999