diff --git a/Makefile.include b/Makefile.include index 7534453b53..f9299f7a5f 100644 --- a/Makefile.include +++ b/Makefile.include @@ -895,6 +895,10 @@ debug: $(DEBUGDEPS) $(call check_cmd,$(DEBUGGER),Debug program) $(DEBUGGER) $(DEBUGGER_FLAGS) +debug-client: + $(call check_cmd,$(DEBUGCLIENT),Debug client program) + $(DEBUGCLIENT) $(DEBUGCLIENT_FLAGS) + debug-server: $(call check_cmd,$(DEBUGSERVER),Debug server program) $(DEBUGSERVER) $(DEBUGSERVER_FLAGS) diff --git a/dist/tools/buildsystem_sanity_check/check.sh b/dist/tools/buildsystem_sanity_check/check.sh index 4884e5fb5b..9ee0eb0eee 100755 --- a/dist/tools/buildsystem_sanity_check/check.sh +++ b/dist/tools/buildsystem_sanity_check/check.sh @@ -107,6 +107,7 @@ UNEXPORTED_VARIABLES+=('FLASHER' 'FFLAGS') UNEXPORTED_VARIABLES+=('RESET' 'RESETFLAGS') UNEXPORTED_VARIABLES+=('DEBUGGER' 'DEBUGGER_FLAGS') UNEXPORTED_VARIABLES+=('DEBUGSERVER' 'DEBUGSERVER_FLAGS') +UNEXPORTED_VARIABLES+=('DEBUGCLIENT' 'DEBUGCLIENT_FLAGS') UNEXPORTED_VARIABLES+=('PREFLASHER' 'PREFFLAGS' 'FLASHDEPS') UNEXPORTED_VARIABLES+=('OPENOCD_DEBUG_ADAPTER' 'DEBUG_ADAPTER_ID') UNEXPORTED_VARIABLES+=('PROGRAMMER_SERIAL') diff --git a/dist/tools/openocd/openocd.sh b/dist/tools/openocd/openocd.sh index 91b0bf554e..062874e410 100755 --- a/dist/tools/openocd/openocd.sh +++ b/dist/tools/openocd/openocd.sh @@ -50,6 +50,11 @@ # TELNET_PORT: port opened for telnet connections # DBG: debugger client command, default: 'gdb -q' # TUI: if TUI!=null, the -tui option will be used +# debug-client: debug-client +# connects to a running debug-server +# GDB_PORT: port opened for GDB connections +# DBG: debugger client command, default: 'gdb -q' +# TUI: if TUI!=null, the -tui option will be used # # debugr: debug # debug given file on the target but flash it first directly @@ -349,6 +354,21 @@ do_flash() { echo 'Done flashing' } +do_debugclient() { + ELFFILE=$1 + test_elffile + # Export to be able to access these from the sh -c command lines, may be + # useful when using a frontend for GDB + export ELFFILE + export GDB + export GDB_PORT + export DBG_FLAGS + export DBG_DEFAULT_FLAGS + export DBG_EXTRA_FLAGS + # Start the debugger and connect to the GDB server + sh -c "${DBG} ${DBG_FLAGS} ${ELFFILE}" +} + do_debug() { ELFFILE=$1 test_config @@ -380,16 +400,7 @@ do_debug() { ${OPENOCD_DBG_START_CMD} \ -l /dev/null & \ echo \$! > $OCD_PIDFILE" & - # Export to be able to access these from the sh -c command lines, may be - # useful when using a frontend for GDB - export ELFFILE - export GDB - export GDB_PORT - export DBG_FLAGS - export DBG_DEFAULT_FLAGS - export DBG_EXTRA_FLAGS - # Start the debugger and connect to the GDB server - sh -c "${DBG} ${DBG_FLAGS} ${ELFFILE}" + do_debugclient ${ELFFILE} } do_debugserver() { @@ -490,6 +501,10 @@ case "${ACTION}" in echo "### Starting Debugging ###" do_debug "$@" ;; + debug-client) + echo "### Attaching to GDB Server ###" + do_debugclient "$@" + ;; debug-server) echo "### Starting GDB Server ###" do_debugserver diff --git a/drivers/sx127x/sx127x_getset.c b/drivers/sx127x/sx127x_getset.c index feba720ec0..a365f61bca 100644 --- a/drivers/sx127x/sx127x_getset.c +++ b/drivers/sx127x/sx127x_getset.c @@ -117,9 +117,10 @@ void sx127x_set_syncword(sx127x_t *dev, uint8_t syncword) uint32_t sx127x_get_channel(const sx127x_t *dev) { - return (((uint32_t)sx127x_reg_read(dev, SX127X_REG_FRFMSB) << 16) | - (sx127x_reg_read(dev, SX127X_REG_FRFMID) << 8) | - (sx127x_reg_read(dev, SX127X_REG_FRFLSB))) * LORA_FREQUENCY_RESOLUTION_DEFAULT; + uint32_t raw = ((uint32_t)sx127x_reg_read(dev, SX127X_REG_FRFMSB) << 16) + | ((uint32_t)sx127x_reg_read(dev, SX127X_REG_FRFMID) << 8) + | ((uint32_t)sx127x_reg_read(dev, SX127X_REG_FRFLSB)); + return (uint64_t)raw * LORA_FREQUENCY_RESOLUTION_NANOHERTZ_DEFAULT / 1000000000U; } void sx127x_set_channel(sx127x_t *dev, uint32_t channel) @@ -129,7 +130,7 @@ void sx127x_set_channel(sx127x_t *dev, uint32_t channel) /* Save current operating mode */ dev->settings.channel = channel; - channel = (uint32_t)((double)channel / (double)LORA_FREQUENCY_RESOLUTION_DEFAULT); + channel = (uint64_t)channel * 1000000000U / LORA_FREQUENCY_RESOLUTION_NANOHERTZ_DEFAULT; /* Write frequency settings into chip */ sx127x_reg_write(dev, SX127X_REG_FRFMSB, (uint8_t)((channel >> 16) & 0xFF)); diff --git a/drivers/sx127x/sx127x_internal.c b/drivers/sx127x/sx127x_internal.c index d3b86b40ae..0aa45c1f8d 100644 --- a/drivers/sx127x/sx127x_internal.c +++ b/drivers/sx127x/sx127x_internal.c @@ -120,11 +120,10 @@ void sx1276_rx_chain_calibration(sx127x_t *dev) /* Save context */ reg_pa_config_init_val = sx127x_reg_read(dev, SX127X_REG_PACONFIG); - initial_freq = (double)(((uint32_t)sx127x_reg_read(dev, SX127X_REG_FRFMSB) << 16) - | ((uint32_t)sx127x_reg_read(dev, SX127X_REG_FRFMID) << 8) - | ((uint32_t)sx127x_reg_read(dev, - SX127X_REG_FRFLSB))) * - (double)LORA_FREQUENCY_RESOLUTION_DEFAULT; + initial_freq = ((uint32_t)sx127x_reg_read(dev, SX127X_REG_FRFMSB) << 16) + | ((uint32_t)sx127x_reg_read(dev, SX127X_REG_FRFMID) << 8) + | ((uint32_t)sx127x_reg_read(dev, SX127X_REG_FRFLSB)); + initial_freq = (uint64_t)initial_freq * LORA_FREQUENCY_RESOLUTION_NANOHERTZ_DEFAULT / 1000000000U; /* Cut the PA just in case, RFO output, power = -1 dBm */ sx127x_reg_write(dev, SX127X_REG_PACONFIG, 0x00); diff --git a/makefiles/info.inc.mk b/makefiles/info.inc.mk index f6a4619a30..922ded24ac 100644 --- a/makefiles/info.inc.mk +++ b/makefiles/info.inc.mk @@ -119,6 +119,9 @@ info-build: @echo 'DEBUGSERVER: $(DEBUGSERVER)' @echo 'DEBUGSERVER_FLAGS: $(DEBUGSERVER_FLAGS)' @echo '' + @echo 'DEBUGCLIENT: $(DEBUGCLIENT)' + @echo 'DEBUGCLIENT_FLAGS: $(DEBUGCLIENT_FLAGS)' + @echo '' @echo 'RESET: $(RESET)' @echo 'RESET_FLAGS: $(RESET_FLAGS)' @echo '' diff --git a/makefiles/tools/openocd.inc.mk b/makefiles/tools/openocd.inc.mk index b5d3e36244..4a7a3aa8bc 100644 --- a/makefiles/tools/openocd.inc.mk +++ b/makefiles/tools/openocd.inc.mk @@ -1,12 +1,14 @@ FLASHER ?= $(RIOTTOOLS)/openocd/openocd.sh DEBUGGER ?= $(RIOTTOOLS)/openocd/openocd.sh DEBUGSERVER ?= $(RIOTTOOLS)/openocd/openocd.sh +DEBUGCLIENT ?= $(RIOTTOOLS)/openocd/openocd.sh RESET ?= $(RIOTTOOLS)/openocd/openocd.sh FLASHFILE ?= $(ELFFILE) FFLAGS ?= flash $(FLASHFILE) DEBUGGER_FLAGS ?= debug $(DEBUG_ELFFILE) DEBUGSERVER_FLAGS ?= debug-server +DEBUGCLIENT_FLAGS ?= debug-client $(DEBUG_ELFFILE) RESET_FLAGS ?= reset ifneq (,$(OPENOCD_DEBUG_ADAPTER)) @@ -44,7 +46,7 @@ ifneq (,$(OPENOCD_CMD_RESET_HALT)) $(call target-export-variables,flash-only,OPENOCD_CMD_RESET_HALT) endif -OPENOCD_DEBUG_TARGETS = debug debugr debug-server +OPENOCD_DEBUG_TARGETS = debug debugr debug-server debug-client ifneq (,$(OPENOCD_DBG_EXTRA_CMD)) # Export OPENOCD_DBG_EXTRA_CMD only to the flash/flash-only target diff --git a/makefiles/vars.inc.mk b/makefiles/vars.inc.mk index eec39e761a..9c35946e8f 100644 --- a/makefiles/vars.inc.mk +++ b/makefiles/vars.inc.mk @@ -110,6 +110,8 @@ export HEXFILE # The 'intel hex' stripped result of the compilatio # DEBUGGER_FLAGS # The parameters to supply to DEBUGGER. # DEBUGSERVER # The command to call on "make debug-server", usually a script starting the GDB server. # DEBUGSERVER_FLAGS # The parameters to supply to DEBUGSERVER. +# DEBUGCLIENT # The command to call on "make debug-client", usually a script starting the GDB client. +# DEBUGCLIENT_FLAGS # The parameters to supply to DEBUGCLIENT. # DEVELHELP # Set to 1 to spend ROM, RAM and CPU time for help during development (e.g. enable asserts()) # RESET # The command to call on "make reset", this command resets/reboots the target. # RESET_FLAGS # The parameters to supply to RESET. diff --git a/sys/include/net/lora.h b/sys/include/net/lora.h index be61195db8..24ccce6a60 100644 --- a/sys/include/net/lora.h +++ b/sys/include/net/lora.h @@ -35,9 +35,13 @@ extern "C" { * @ingroup config * @{ */ -/** @brief Frequency resolution in Hz */ -#ifndef LORA_FREQUENCY_RESOLUTION_DEFAULT -#define LORA_FREQUENCY_RESOLUTION_DEFAULT (61.03515625) +#ifndef LORA_FREQUENCY_RESOLUTION_NANOHERTZ_DEFAULT +/** + * @brief Frequency resolution in nano Hz + * + * This is the same as `(32 * 10^15) >> 19` + */ +#define LORA_FREQUENCY_RESOLUTION_NANOHERTZ_DEFAULT 61035156250 #endif /** @brief Preamble length, same for Tx and Rx