From 9d403d95ce35da824d510db495db0025c3f72502 Mon Sep 17 00:00:00 2001 From: daniel-k Date: Tue, 6 Oct 2015 11:37:49 +0200 Subject: [PATCH] cortex_m: Add debug symbols for OpenOCD/GDB thread support --- boards/airfy-beacon/dist/openocd.cfg | 1 + boards/ek-lm4f120xl/dist/openocd.cfg | 1 + boards/fox/dist/openocd.cfg | 1 + boards/frdm-k64f/dist/openocd.cfg | 1 + boards/iotlab-a8-m3/dist/openocd.cfg | 1 + boards/iotlab-m3/dist/openocd.cfg | 1 + boards/limifrog-v1/dist/openocd.cfg | 1 + boards/msbiot/dist/openocd.cfg | 1 + boards/nucleo-f072/dist/openocd.cfg | 1 + boards/nucleo-f091/dist/openocd.cfg | 1 + boards/nucleo-f103/dist/openocd.cfg | 1 + boards/nucleo-f303/dist/openocd.cfg | 1 + boards/nucleo-f334/dist/openocd.cfg | 1 + boards/nucleo-f401/dist/openocd.cfg | 1 + boards/nucleo-l1/dist/openocd.cfg | 1 + boards/pba-d-01-kw2x/dist/openocd.cfg | 1 + boards/saml21-xpro/dist/openocd.cfg | 1 + boards/samr21-xpro/dist/openocd.cfg | 1 + boards/stm32f0discovery/dist/openocd.cfg | 1 + boards/stm32f3discovery/dist/openocd.cfg | 1 + boards/stm32f4discovery/dist/openocd.cfg | 1 + boards/yunjia-nrf51822/dist/openocd.cfg | 1 + core/sched.c | 11 +++++++++++ cpu/cortexm_common/ldscripts/cortexm_base.ld | 1 + 24 files changed, 34 insertions(+) diff --git a/boards/airfy-beacon/dist/openocd.cfg b/boards/airfy-beacon/dist/openocd.cfg index 111ca5e77..6d346ee82 100644 --- a/boards/airfy-beacon/dist/openocd.cfg +++ b/boards/airfy-beacon/dist/openocd.cfg @@ -3,3 +3,4 @@ transport select hla_swd set WORKAREASIZE 0x4000 source [find target/nrf51.cfg] +$_TARGETNAME configure -rtos auto diff --git a/boards/ek-lm4f120xl/dist/openocd.cfg b/boards/ek-lm4f120xl/dist/openocd.cfg index b2ebfa8cf..28e8f46c1 100644 --- a/boards/ek-lm4f120xl/dist/openocd.cfg +++ b/boards/ek-lm4f120xl/dist/openocd.cfg @@ -15,3 +15,4 @@ transport select hla_jtag set WORKAREASIZE 0x8000 set CHIPNAME lm4f120h5qr source [find target/stellaris.cfg] +$_TARGETNAME configure -rtos auto diff --git a/boards/fox/dist/openocd.cfg b/boards/fox/dist/openocd.cfg index fe70f18cf..6b7b7a59d 100644 --- a/boards/fox/dist/openocd.cfg +++ b/boards/fox/dist/openocd.cfg @@ -13,3 +13,4 @@ jtag_ntrst_delay 100 reset_config trst_and_srst source [find target/stm32f1x.cfg] +$_TARGETNAME configure -rtos auto diff --git a/boards/frdm-k64f/dist/openocd.cfg b/boards/frdm-k64f/dist/openocd.cfg index 10b7b1c0d..85d81531a 100644 --- a/boards/frdm-k64f/dist/openocd.cfg +++ b/boards/frdm-k64f/dist/openocd.cfg @@ -48,3 +48,4 @@ adapter_khz 1000 $_TARGETNAME configure -event gdb-attach { halt } +$_TARGETNAME configure -rtos auto diff --git a/boards/iotlab-a8-m3/dist/openocd.cfg b/boards/iotlab-a8-m3/dist/openocd.cfg index efd4f0c32..d9b598536 100644 --- a/boards/iotlab-a8-m3/dist/openocd.cfg +++ b/boards/iotlab-a8-m3/dist/openocd.cfg @@ -6,3 +6,4 @@ ftdi_layout_signal nTRST -data 0x0800 ftdi_layout_signal nSRST -data 0x0400 source [find target/stm32f1x.cfg] +$_TARGETNAME configure -rtos auto diff --git a/boards/iotlab-m3/dist/openocd.cfg b/boards/iotlab-m3/dist/openocd.cfg index efd4f0c32..d9b598536 100644 --- a/boards/iotlab-m3/dist/openocd.cfg +++ b/boards/iotlab-m3/dist/openocd.cfg @@ -6,3 +6,4 @@ ftdi_layout_signal nTRST -data 0x0800 ftdi_layout_signal nSRST -data 0x0400 source [find target/stm32f1x.cfg] +$_TARGETNAME configure -rtos auto diff --git a/boards/limifrog-v1/dist/openocd.cfg b/boards/limifrog-v1/dist/openocd.cfg index 2bf52e066..530d12f68 100644 --- a/boards/limifrog-v1/dist/openocd.cfg +++ b/boards/limifrog-v1/dist/openocd.cfg @@ -3,3 +3,4 @@ transport select hla_swd set WORKAREASIZE 0x2800 source [find target/stm32l1.cfg] +$_TARGETNAME configure -rtos auto diff --git a/boards/msbiot/dist/openocd.cfg b/boards/msbiot/dist/openocd.cfg index 0350e7eba..a2f4a9204 100644 --- a/boards/msbiot/dist/openocd.cfg +++ b/boards/msbiot/dist/openocd.cfg @@ -1 +1,2 @@ source [find board/stm32f4discovery.cfg] +$_TARGETNAME configure -rtos auto diff --git a/boards/nucleo-f072/dist/openocd.cfg b/boards/nucleo-f072/dist/openocd.cfg index 4f0cfb3a0..ba0fc41df 100644 --- a/boards/nucleo-f072/dist/openocd.cfg +++ b/boards/nucleo-f072/dist/openocd.cfg @@ -1 +1,2 @@ source [find board/st_nucleo_f0.cfg] +$_TARGETNAME configure -rtos auto diff --git a/boards/nucleo-f091/dist/openocd.cfg b/boards/nucleo-f091/dist/openocd.cfg index 4f0cfb3a0..ba0fc41df 100644 --- a/boards/nucleo-f091/dist/openocd.cfg +++ b/boards/nucleo-f091/dist/openocd.cfg @@ -1 +1,2 @@ source [find board/st_nucleo_f0.cfg] +$_TARGETNAME configure -rtos auto diff --git a/boards/nucleo-f103/dist/openocd.cfg b/boards/nucleo-f103/dist/openocd.cfg index 82df176c4..befcac325 100755 --- a/boards/nucleo-f103/dist/openocd.cfg +++ b/boards/nucleo-f103/dist/openocd.cfg @@ -1,2 +1,3 @@ #source [find board/st_nucleo_f1.cfg] source [find board/st_nucleo_f103rb.cfg] +$_TARGETNAME configure -rtos auto diff --git a/boards/nucleo-f303/dist/openocd.cfg b/boards/nucleo-f303/dist/openocd.cfg index 248900753..915eebc91 100755 --- a/boards/nucleo-f303/dist/openocd.cfg +++ b/boards/nucleo-f303/dist/openocd.cfg @@ -1 +1,2 @@ source [find board/st_nucleo_f3.cfg] +$_TARGETNAME configure -rtos auto diff --git a/boards/nucleo-f334/dist/openocd.cfg b/boards/nucleo-f334/dist/openocd.cfg index 248900753..915eebc91 100644 --- a/boards/nucleo-f334/dist/openocd.cfg +++ b/boards/nucleo-f334/dist/openocd.cfg @@ -1 +1,2 @@ source [find board/st_nucleo_f3.cfg] +$_TARGETNAME configure -rtos auto diff --git a/boards/nucleo-f401/dist/openocd.cfg b/boards/nucleo-f401/dist/openocd.cfg index 9a3061f0b..27ae019ae 100644 --- a/boards/nucleo-f401/dist/openocd.cfg +++ b/boards/nucleo-f401/dist/openocd.cfg @@ -1 +1,2 @@ source [find board/st_nucleo_f4.cfg] +$_TARGETNAME configure -rtos auto diff --git a/boards/nucleo-l1/dist/openocd.cfg b/boards/nucleo-l1/dist/openocd.cfg index 1553507ee..939ea7d89 100644 --- a/boards/nucleo-l1/dist/openocd.cfg +++ b/boards/nucleo-l1/dist/openocd.cfg @@ -1 +1,2 @@ source [find board/st_nucleo_l1.cfg] +$_TARGETNAME configure -rtos auto diff --git a/boards/pba-d-01-kw2x/dist/openocd.cfg b/boards/pba-d-01-kw2x/dist/openocd.cfg index 806b323bb..f2fb040b8 100644 --- a/boards/pba-d-01-kw2x/dist/openocd.cfg +++ b/boards/pba-d-01-kw2x/dist/openocd.cfg @@ -69,3 +69,4 @@ if {![using_hla]} { $_TARGETNAME configure -event reset-init { adapter_khz 24000 } +$_TARGETNAME configure -rtos auto diff --git a/boards/saml21-xpro/dist/openocd.cfg b/boards/saml21-xpro/dist/openocd.cfg index 2070f15e3..318649808 100644 --- a/boards/saml21-xpro/dist/openocd.cfg +++ b/boards/saml21-xpro/dist/openocd.cfg @@ -1 +1,2 @@ source [find board/atmel_saml21_xplained_pro.cfg] +$_TARGETNAME configure -rtos auto diff --git a/boards/samr21-xpro/dist/openocd.cfg b/boards/samr21-xpro/dist/openocd.cfg index 2c81bdfbf..597b433bc 100644 --- a/boards/samr21-xpro/dist/openocd.cfg +++ b/boards/samr21-xpro/dist/openocd.cfg @@ -1 +1,2 @@ source [find board/atmel_samr21_xplained_pro.cfg] +$_TARGETNAME configure -rtos auto diff --git a/boards/stm32f0discovery/dist/openocd.cfg b/boards/stm32f0discovery/dist/openocd.cfg index 7cc0fd890..9a408c9d1 100644 --- a/boards/stm32f0discovery/dist/openocd.cfg +++ b/boards/stm32f0discovery/dist/openocd.cfg @@ -1 +1,2 @@ source [find board/stm32f0discovery.cfg] +$_TARGETNAME configure -rtos auto diff --git a/boards/stm32f3discovery/dist/openocd.cfg b/boards/stm32f3discovery/dist/openocd.cfg index f032f7a0c..d164f1c15 100644 --- a/boards/stm32f3discovery/dist/openocd.cfg +++ b/boards/stm32f3discovery/dist/openocd.cfg @@ -1 +1,2 @@ source [find board/stm32f3discovery.cfg] +$_TARGETNAME configure -rtos auto diff --git a/boards/stm32f4discovery/dist/openocd.cfg b/boards/stm32f4discovery/dist/openocd.cfg index 0350e7eba..a2f4a9204 100644 --- a/boards/stm32f4discovery/dist/openocd.cfg +++ b/boards/stm32f4discovery/dist/openocd.cfg @@ -1 +1,2 @@ source [find board/stm32f4discovery.cfg] +$_TARGETNAME configure -rtos auto diff --git a/boards/yunjia-nrf51822/dist/openocd.cfg b/boards/yunjia-nrf51822/dist/openocd.cfg index 111ca5e77..6d346ee82 100644 --- a/boards/yunjia-nrf51822/dist/openocd.cfg +++ b/boards/yunjia-nrf51822/dist/openocd.cfg @@ -3,3 +3,4 @@ transport select hla_swd set WORKAREASIZE 0x4000 source [find target/nrf51.cfg] +$_TARGETNAME configure -rtos auto diff --git a/core/sched.c b/core/sched.c index 151649aad..767b26f54 100644 --- a/core/sched.c +++ b/core/sched.c @@ -53,6 +53,17 @@ volatile kernel_pid_t sched_active_pid = KERNEL_PID_UNDEF; clist_node_t sched_runqueues[SCHED_PRIO_LEVELS]; static uint32_t runqueue_bitcache = 0; +/* Needed by OpenOCD to read sched_threads */ +__attribute__((used)) __attribute__((section (".openocd"))) +uint8_t max_threads = sizeof(sched_threads) / sizeof(thread_t*); + +#ifdef DEVELHELP +/* OpenOCD can't determine struct offsets and additionally this member is only + * available if compiled with DEVELHELP */ +__attribute__((used)) __attribute__((section (".openocd"))) +uint8_t _tcb_name_offset = offsetof(thread_t, name); +#endif + #ifdef MODULE_SCHEDSTATISTICS static void (*sched_cb) (uint32_t timestamp, uint32_t value) = NULL; schedstat sched_pidlist[KERNEL_PID_LAST + 1]; diff --git a/cpu/cortexm_common/ldscripts/cortexm_base.ld b/cpu/cortexm_common/ldscripts/cortexm_base.ld index 5165aa088..bbfa3aaec 100644 --- a/cpu/cortexm_common/ldscripts/cortexm_base.ld +++ b/cpu/cortexm_common/ldscripts/cortexm_base.ld @@ -117,6 +117,7 @@ SECTIONS _srelocate = .; *(.ramfunc .ramfunc.*); *(.data .data.*); + KEEP (*(.openocd .openocd.*)) . = ALIGN(4); _erelocate = .; } > ram