I was not able to reproduce your exact problem but there is an issue using the 
nrf51 with the sx1276 driver as it currently exists. The sx1276 code is 
attempting to install a number of gpio irqs. The nrf51 only allows 4 of them so 
the code will assert when trying to enable more than 4 gpio irqs.

This is an aside, but setting SPI_0_MASTER_SS_PIN is not the SX1276 chip select 
I was referring to. You need to set SX1276_CS_PIN to the value you want. Here 
is the target I used for testing:

wes@~/dev/wes$ newt target show nrf51_lora_app_shell
targets/nrf51_lora_app_shell
    app=@apache-mynewt-core/apps/lora_app_shell
    bsp=@apache-mynewt-core/hw/bsp/nrf51dk
    build_profile=optimized
    
syscfg=LORA_MAC_TIMER_NUM=2:LORA_NODE_DEFAULT_DATARATE=0:LORA_NODE_FREQ_BAND=916:MSYS_1_BLOCK_COUNT=32:MSYS_1_BLOCK_SIZE=132:OC_TRANSPORT_LORA=1:SHELL_CMD_ARGC_MAX=20:SPI_0_MASTER=1:SX1276_SPI_CS_PIN=22:SX1276_SPI_IDX=0:TIMER_2=1

Note that some of these settings are in the telee02 bsp syscfg.yml. I just set 
them in my target for quick testing. Some of these settings are not necessary 
either. I would say use all of them except for the LORA_NODE_FREQ_BAND. That 
needs to be set based on the frequency band you want to use for your device.


> On Nov 30, 2017, at 1:51 AM, K Dmitry <dimka...@yandex.ru> wrote:
> 
> 29.11.2017, 21:34, "marko kiiskila" <ma...@runtime.io>:
>> 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" <wi...@runtime.io>:
>> 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