Well, it looks like it is crashing in os_init() which is very odd at the call 
to os_arch_os_init() assuming I am reading your backtrace correctly and my line 
#’s and yours match.

One thing about the SPI pins: those -D variables you changed are used by the 
nordic SDK and are not the ones you want to change (presumably). You really 
want to change the pins in hal_bsp.c in the structure I mentioned.

That should not cause your issue though.

Let me see if I can reproduce your issue…

> On Nov 30, 2017, at 1:51 AM, K Dmitry <[email protected]> wrote:
> 
> 29.11.2017, 21:34, "marko kiiskila" <[email protected]>:
>> I don’t think the system is even booting properly.
>> If you run it under debugger, can you verify that you’re not reaching main()?
> 
> Looks like it crashes before reaching main:
> (gdb) load
> Loading section .text, size 0x119a8 lma 0x8020
> Loading section .ARM.exidx, size 0x18 lma 0x199c8
> Loading section .data, size 0x25c lma 0x199e0
> Start address 0x80e0, load size 72732
> Transfer rate: 11837 KB/sec, 10390 bytes/write.
> (gdb) bt
> #0  Reset_Handler () at 
> repos/apache-mynewt-core/hw/bsp/nrf51dk/src/arch/cortex_m0/gcc_startup_nrf51.s:140
> (gdb) b main
> Breakpoint 1 at 0x84dc: file 
> repos/apache-mynewt-core/apps/lora_app_shell/src/main.c, line 128.
> (gdb) c
> Continuing.
> 
> Program received signal SIGTRAP, Trace/breakpoint trap.
> 0xfffffffe in ?? ()
> (gdb) bt
> #0  0xfffffffe in ?? ()
> #1  0x0000edea in console_out (c=48) at 
> repos/apache-mynewt-core/sys/console/full/src/uart_console.c:142
> #2  0x0000e8f0 in console_write (str=<optimized out>, cnt=cnt@entry=1) at 
> repos/apache-mynewt-core/sys/console/full/src/console.c:99
> #3  0x000140b8 in stdout_write (fp=<optimized out>, bp=<optimized out>, n=1) 
> at repos/apache-mynewt-core/libc/baselibc/src/mynewt.c:32
> #4  0x000142b8 in fwrite (stream=0x140b9 <stdout_write+12>, nmemb=1, size=1, 
> buf=0x20007dff)
>    at repos/apache-mynewt-core/libc/baselibc/include/stdio.h:59
> #5  fputc (f=0x140b9 <stdout_write+12>, c=48) at 
> repos/apache-mynewt-core/libc/baselibc/include/stdio.h:75
> #6  putf (putp=putp@entry=0x20000318 <_stdin>, c=c@entry=48 '0') at 
> repos/apache-mynewt-core/libc/baselibc/src/tinyprintf.c:137
> #7  0x000143a8 in putchw (putp=putp@entry=0x20000318 <_stdin>, 
> p=p@entry=0x20007e48)
>    at repos/apache-mynewt-core/libc/baselibc/src/tinyprintf.c:181
> #8  0x000145ba in tfp_format (putp=0x20000318 <_stdin>, fmt=0x18bc5 " ", 
> fmt@entry=0x1 "\200", va=...)
>    at repos/apache-mynewt-core/libc/baselibc/src/tinyprintf.c:302
> #9  0x00014714 in vfprintf (va=..., fmt=0x1 "\200", f=<optimized out>) at 
> repos/apache-mynewt-core/libc/baselibc/src/tinyprintf.c:355
> #10 printf (fmt=0x18bc0 "%06lu ") at 
> repos/apache-mynewt-core/libc/baselibc/src/tinyprintf.c:371
> #11 0x0000ec58 in console_printf (fmt=0x180e0 "Assert @ 0x%x\n") at 
> repos/apache-mynewt-core/sys/console/full/src/console_fmt.c:50
> #12 0x00009054 in __assert_func (file=file@entry=0x18204 
> "repos/apache-mynewt-core/kernel/os/src/os.c", line=line@entry=186, 
>    func=func@entry=0x0, e=e@entry=0x0) at 
> repos/apache-mynewt-core/kernel/os/src/arch/cortex_m0/os_fault.c:119
> #13 0x00009258 in os_init (main_fn=0x84dd <main>) at 
> repos/apache-mynewt-core/kernel/os/src/os.c:186
> #14 0x000082ec in _start () at 
> repos/apache-mynewt-core/libc/baselibc/src/start.c:37
> #15 0x00008122 in Reset_Handler () at 
> repos/apache-mynewt-core/hw/bsp/nrf51dk/src/arch/cortex_m0/gcc_startup_nrf51.s:189
> Backtrace stopped: previous frame identical to this frame (corrupt stack?)
> 
> 
> 
> 
> 29.11.2017, 22:21, "will sanfilippo" <[email protected]>:
>> Actually, TIMER_3 is not the correct timer to use. The lora code currently 
>> does not use the RTC timer so you need a different timer to run lora. I 
>> would use TIMER_2 to do this for the nrf51.
> 
> I've changed timer to 2 and rebuilt and reloaded app - no changes.
> 
> $ newt target show
> targets/nrf51lora_app
>    app=@apache-mynewt-core/apps/lora_app_shell
>    bsp=@apache-mynewt-core/hw/bsp/nrf51dk
>    build_profile=debug
> syscfg=BASELIBC_ASSERT_FILE_LINE=1:LORA_MAC_TIMER_NUM=2:SHELL_CMD_ARGC_MAX=20:SYSINIT_PANIC_FILE_LINE=1:SYSINIT_PANIC_MESSAGE=1:TIMER_2=1
> 
> 
>> I also presume that you found the definitions for the various GPIO that 
>> connect the sx1276 to the main cpu. These are currently defined in bsp.h in 
>> hw/bsp/telee02. The SPI pin definitions are in mixed places:
>> * The SPI CS pin is in syscfg.yml.
>> * The SCK, MOSI and MISO definitions are in hal_bsp.c in static const struct 
>> nrf52_hal_spi_cfg os_bsp_spi0m_cfg
> 
> SPI_SS in defined in repos/apache-mynewt-core/hw/bsp/nrf51dk/syscfg.yml
> SPI_0_MASTER_SS_PIN:
>     description: 'SPI 0 (master) SS pin number.'
>     value:  24
> 
> 
> Other SPI pins are defined at 
> ./repos/apache-mynewt-core/hw/bsp/nrf51dk/pkg.yml in section pkg.cflags
> So I use pins 24,25,28,29 for SPI.
> 
>    - '-DSPI0_CONFIG_MISO_PIN=28'
>    - '-DSPI0_CONFIG_MOSI_PIN=25'
>    - '-DSPI0_CONFIG_SCK_PIN=29'
>    - '-DSPI0_ENABLED=1'
>    - '-DSPI0_USE_EASY_DMA=0'
>    - '-DSPI1_ENABLED=0'
>    - '-DSPI2_ENABLED=0'
>    - '-DSPIS0_CONFIG_MISO_PIN=4'
>    - '-DSPIS0_CONFIG_MOSI_PIN=3'
>    - '-DSPIS0_CONFIG_SCK_PIN=2'
>    - '-DSPIS0_ENABLED=0'
>    - '-DSPIS1_CONFIG_MISO_PIN=28'
>    - '-DSPIS1_CONFIG_MOSI_PIN=25'
>    - '-DSPIS1_CONFIG_SCK_PIN=29'
>    - '-DSPIS1_ENABLED=1'
>    - '-DSPIS2_ENABLED=0'
> 
> 
> 
> 
> SX1276 pins I copied from 
> ./repos/apache-mynewt-core/hw/bsp/telee02/include/bsp/bsp.h to 
> repos/apache-mynewt-core/hw/bsp/nrf51dk/include/bsp/bsp.h
> 
> #define SX1276_DIO0         (01)
> #define SX1276_DIO1         (02)
> #define SX1276_DIO2         (03)
> #define SX1276_DIO3         (04)
> #define SX1276_DIO4         (05)
> #define SX1276_DIO5         (06)
> #define SX1276_NRESET       (12)
> #define SX1276_RXTX         (13)
> #define SX1276_ANT_HF_CTRL  (14)
> 
> 
>> 
>> A case could be made to have all of these definitions as configurable MYNEWT 
>> variables in the lora driver itself and then have them overridden by a 
>> custom bsp or in the target but for now you will either have to create your 
>> own bsp and make these modifications or locally modify your nrf51dk bsp.
> 
> That would be nice. It was quite puzzling to search for these definitions 
> scattered all over the sources.
> 
> 
>> Lastly: did you build and load the bootloader on this device? I see that you 
>> have a bootloader target but I did not see in the list of commands if you 
>> built and loaded it.
> 
> Sure. I loaded it while was playing with slinky example. And loading slinky 
> instead of lora app works fine.
> 

Reply via email to