Porting to new LiFePO4wered/LoRa board

btw: I think your logs look good to me. I’d recommend as next steps:

  • Define USE_SIM_RADIO, to temporarily turn off the SPI radio
  • Make sure the board boots and your buttons work (for GPIO testing)
  • then turn USE_SIM_RADIO off and double check the GPIOs you’ve got assigned to SPI in your variant.h

Thanks @geeksville, USE_SIM_RADIO is very useful. Here is a log with that:

??:??:?? 0 Emitting reboot packet for serial shell
��␀␂H␁??:??:?? 0 Filesystem files:
??:??:?? 0 I2C device found at address 0x3c
??:??:?? 0 ssd1306 display found
??:??:?? 0 I2C device found at address 0x59
??:??:?? 0 done
??:??:?? 0 Meshtastic swver=1.1.50, hwver=unset
??:??:?? 0 Reset reason: 0x4
??:??:?? 0 FIXME, call randomSeed
??:??:?? 0 Setting default preferences!
??:??:?? 0 Expanding short PSK #1
??:??:?? 0 Wanted region 0, using Unset
??:??:?? 0 Initial packet id 1481765933, numPacketId 4294967295
??:??:?? 0 No saved preferences found
??:??:?? 0 This build does not specify a HW_VERSION
??:??:?? 0 Expanding short PSK #1
??:??:?? 0 Wanted region 0, using Unset
??:??:?? 0 legacy_region=, region=0, NODENUM=0xe31bc5f, dbsize=1
??:??:?? 0 Warning: No GPS found - running without GPS
??:??:?? 0 Turning on screen
??:??:?? 0 Using SIMULATED radio!
??:??:?? 0 PowerFSM init, USB power=1
??:??:?? 0 [Screen] Screen: Started...
Transition powerFSM transition=boot timeout, from=BOOT to=POWER
??:??:?? 3 [PowerFSM] DISABLING NRF52 BLUETOOTH WHILE DEBUGGING
??:??:?? 3 [Screen] Screen: Powered...
??:??:?? 5 [Screen] Done with boot screen...
??:??:?? 5 [Screen] showing standard frames
??:??:?? 5 [Screen] Showing 0 plugin frames
??:??:?? 5 [Screen] Total frame count: 35
??:??:?? 5 [Screen] Added plugins.  numframes: 0
??:??:?? 5 [Screen] Finished building frames. numframes: 2
??:??:?? 5 [Screen] Setting fast framerate
??:??:?? 5 [Screen] Setting idle framerate
??:??:?? 30 [NodeInfoPlugin] Sending our nodeinfo to mesh (wantReplies=1)
??:??:?? 30 [NodeInfoPlugin] sending owner !0e31bc5f/Unknown bc5f/?5F
??:??:?? 30 [NodeInfoPlugin] Update DB node 0xe31bc5f, rx_time=0
??:??:?? 30 [NodeInfoPlugin] Received nodeinfo from=0xe31bc5f, id=0x5851f430, payloadlen=38
??:??:?? 30 [NodeInfoPlugin] old user !0e31bc5f/Unknown bc5f/?5F
??:??:?? 30 [NodeInfoPlugin] updating changed=0 user !0e31bc5f/Unknown bc5f/?5F
??:??:?? 30 [NodeInfoPlugin] sending owner !0e31bc5f/Unknown bc5f/?5F
??:??:?? 30 [NodeInfoPlugin] Sending response
??:??:?? 30 [NodeInfoPlugin] Update DB node 0xe31bc5f, rx_time=0
??:??:?? 30 [NodeInfoPlugin] Received nodeinfo from=0xe31bc5f, id=0x5851f431, payloadlen=38
??:??:?? 30 [NodeInfoPlugin] old user !0e31bc5f/Unknown bc5f/?5F
??:??:?? 30 [NodeInfoPlugin] updating changed=0 user !0e31bc5f/Unknown bc5f/?5F
??:??:?? 30 [NodeInfoPlugin] Plugin nodeinfo handled=0
??:??:?? 30 [NodeInfoPlugin] Enqueuing local (id=0x5851f431 Fr0x5f To0x5f, WantAck0, HopLim3 Portnum=4)
??:??:?? 30 [NodeInfoPlugin] Plugin nodeinfo handled=0
??:??:?? 30 [NodeInfoPlugin] Rebroadcasting received floodmsg to neighbors (id=0x5851f430 Fr0x5f To0xff, WantAck0, HopLim3 Portnum=4 WANTRESP priority=10)
??:??:?? 30 [NodeInfoPlugin] SimRadio.send
??:??:?? 30 [NodeInfoPlugin] FIXME-update-db Sniffing packet
??:??:?? 30 [NodeInfoPlugin] Delivering rx packet (id=0x5851f430 Fr0x5f To0xff, WantAck0, HopLim3 Portnum=4 WANTRESP priority=10)
Trigger powerFSM 3
??:??:?? 30 [NodeInfoPlugin] Forwarding to phone (id=0x5851f430 Fr0x5f To0xff, WantAck0, HopLim3 Portnum=4 WANTRESP priority=10)
??:??:?? 30 [NodeInfoPlugin] Update DB node 0xe31bc5f, rx_time=0
??:??:?? 30 [NodeInfoPlugin] Received nodeinfo from=0xe31bc5f, id=0x5851f430, payloadlen=38
??:??:?? 30 [NodeInfoPlugin] old user !0e31bc5f/Unknown bc5f/?5F
??:??:?? 30 [NodeInfoPlugin] updating changed=0 user !0e31bc5f/Unknown bc5f/?5F
??:??:?? 30 [NodeInfoPlugin] sending owner !0e31bc5f/Unknown bc5f/?5F
??:??:?? 30 [NodeInfoPlugin] Sending response
??:??:?? 30 [NodeInfoPlugin] Update DB node 0xe31bc5f, rx_time=0
??:??:?? 30 [NodeInfoPlugin] Received nodeinfo from=0xe31bc5f, id=0x5851f432, payloadlen=38
??:??:?? 30 [NodeInfoPlugin] old user !0e31bc5f/Unknown bc5f/?5F
??:??:?? 30 [NodeInfoPlugin] updating changed=0 user !0e31bc5f/Unknown bc5f/?5F
??:??:?? 30 [NodeInfoPlugin] Plugin nodeinfo handled=0
??:??:?? 30 [NodeInfoPlugin] Enqueuing local (id=0x5851f432 Fr0x5f To0x5f, WantAck0, HopLim3 Portnum=4)
??:??:?? 30 [NodeInfoPlugin] Plugin nodeinfo handled=0
??:??:?? 30 [NodeInfoPlugin] Adding packet record (id=0x5851f430 Fr0x5f To0xff, WantAck0, HopLim3 Portnum=4 WANTRESP priority=10)
??:??:?? 30 [NodeInfoPlugin] SimRadio.send
??:??:?? 30 (Client not yet interested in packets)
??:??:?? 30 [Router] Adding packet record (id=0x5851f431 Fr0x5f To0x5f, WantAck0, HopLim3 Portnum=4)
??:??:?? 30 [Router] FIXME not implemented addRoute
??:??:?? 30 [Router] FIXME-update-db Sniffing packet
??:??:?? 30 [Router] Delivering rx packet (id=0x5851f431 Fr0x5f To0x5f, WantAck0, HopLim3 Portnum=4)
Trigger powerFSM 3
??:??:?? 30 [Router] Forwarding to phone (id=0x5851f431 Fr0x5f To0x5f, WantAck0, HopLim3 Portnum=4)
??:??:?? 30 [Router] Update DB node 0xe31bc5f, rx_time=0
??:??:?? 30 [Router] Received nodeinfo from=0xe31bc5f, id=0x5851f431, payloadlen=38
??:??:?? 30 [Router] old user !0e31bc5f/Unknown bc5f/?5F
??:??:?? 30 [Router] updating changed=0 user !0e31bc5f/Unknown bc5f/?5F
??:??:?? 30 [Router] Plugin nodeinfo handled=0
??:??:?? 30 [Router] Adding packet record (id=0x5851f432 Fr0x5f To0x5f, WantAck0, HopLim3 Portnum=4)
??:??:?? 30 [Router] FIXME not implemented addRoute
??:??:?? 30 [Router] FIXME-update-db Sniffing packet
??:??:?? 30 [Router] Delivering rx packet (id=0x5851f432 Fr0x5f To0x5f, WantAck0, HopLim3 Portnum=4)
Trigger powerFSM 3
??:??:?? 30 [Router] Forwarding to phone (id=0x5851f432 Fr0x5f To0x5f, WantAck0, HopLim3 Portnum=4)
??:??:?? 30 [Router] Update DB node 0xe31bc5f, rx_time=0
??:??:?? 30 [Router] Received nodeinfo from=0xe31bc5f, id=0x5851f432, payloadlen=38
??:??:?? 30 [Router] old user !0e31bc5f/Unknown bc5f/?5F
??:??:?? 30 [Router] updating changed=0 user !0e31bc5f/Unknown bc5f/?5F
??:??:?? 30 [Router] Plugin nodeinfo handled=0
??:??:?? 30 [Screen] Screen: Joined: Unknown bc5f
??:??:?? 30 [Screen] Screen: Joined: Unknown bc5f
??:??:?? 30 (Client not yet interested in packets)

No Bluetooth, but that was likely because I was debugging (“DISABLING NRF52 BLUETOOTH WHILE DEBUGGING”). Changed the flag in main-nrf52.cpp to turn that on:

??:??:?? 0 Emitting reboot packet for serial shell
��H??:??:?? 0 Filesystem files:
??:??:?? 0 I2C device found at address 0x3c
??:??:?? 0 ssd1306 display found
??:??:?? 0 I2C device found at address 0x59
??:??:?? 0 done
??:??:?? 0 Meshtastic swver=1.1.50, hwver=unset
??:??:?? 0 Reset reason: 0x4
??:??:?? 0 FIXME, call randomSeed
??:??:?? 0 Setting default preferences!
??:??:?? 0 Expanding short PSK #1
??:??:?? 0 Wanted region 0, using Unset
??:??:?? 0 Initial packet id 1481765933, numPacketId 4294967295
??:??:?? 0 No saved preferences found
??:??:?? 0 This build does not specify a HW_VERSION
??:??:?? 0 Expanding short PSK #1
??:??:?? 0 Wanted region 0, using Unset
??:??:?? 0 legacy_region=, region=0, NODENUM=0xe31bc5f, dbsize=1
??:??:?? 0 Warning: No GPS found - running without GPS
??:??:?? 0 Turning on screen
??:??:?? 0 Using SIMULATED radio!
??:??:?? 0 PowerFSM init, USB power=1
??:??:?? 0 [Screen] Screen: Started...
Transition powerFSM transition=boot timeout, from=BOOT to=POWER
                                                               ??:??:?? 3 [PowerFSM] Initialise the Bluefr
uit nRF52 module
??:??:?? 3 [PowerFSM] Configuring the Device Information Service
??:??:?? 3 [PowerFSM] Configuring the Battery Service
??:??:?? 3 [PowerFSM] Configuring the Mesh bluetooth service
??:??:?? 3 [PowerFSM] Setting up the advertising payload(s)
??:??:?? 3 [PowerFSM] Advertising
??:??:?? 3 [Screen] Screen: Powered...
??:??:?? 5 [Screen] Done with boot screen...
??:??:?? 5 [Screen] showing standard frames
??:??:?? 5 [Screen] Showing 0 plugin frames
??:??:?? 5 [Screen] Total frame count: 35
??:??:?? 5 [Screen] Added plugins.  numframes: 0
??:??:?? 5 [Screen] Finished building frames. numframes: 2
??:??:?? 5 [Screen] Setting fast framerate
??:??:?? 5 [Screen] Setting idle framerate
??:??:?? 23 BLE Connected to Pixel 3a
??:??:?? 30 [NodeInfoPlugin] Sending our nodeinfo to mesh (wantReplies=1)
??:??:?? 30 [NodeInfoPlugin] sending owner !0e31bc5f/Unknown bc5f/?5F
??:??:?? 30 [NodeInfoPlugin] Update DB node 0xe31bc5f, rx_time=0
??:??:?? 30 [NodeInfoPlugin] Received nodeinfo from=0xe31bc5f, id=0x5851f430, payloadlen=38
??:??:?? 30 [NodeInfoPlugin] old user !0e31bc5f/Unknown bc5f/?5F
??:??:?? 30 [NodeInfoPlugin] updating changed=0 user !0e31bc5f/Unknown bc5f/?5F
??:??:?? 30 [NodeInfoPlugin] sending owner !0e31bc5f/Unknown bc5f/?5F
??:??:?? 30 [NodeInfoPlugin] Sending response
??:??:?? 30 [NodeInfoPlugin] Update DB node 0xe31bc5f, rx_time=0
??:??:?? 30 [NodeInfoPlugin] Received nodeinfo from=0xe31bc5f, id=0x5851f431, payloadlen=38
??:??:?? 30 [NodeInfoPlugin] old user !0e31bc5f/Unknown bc5f/?5F
??:??:?? 30 [NodeInfoPlugin] updating changed=0 user !0e31bc5f/Unknown bc5f/?5F
??:??:?? 30 [NodeInfoPlugin] Plugin nodeinfo handled=0
??:??:?? 30 [NodeInfoPlugin] Enqueuing local (id=0x5851f431 Fr0x5f To0x5f, WantAck0, HopLim3 Portnum=4)
??:??:?? 30 [NodeInfoPlugin] Plugin nodeinfo handled=0
??:??:?? 30 [NodeInfoPlugin] Rebroadcasting received floodmsg to neighbors (id=0x5851f430 Fr0x5f To0xff, W
antAck0, HopLim3 Portnum=4 WANTRESP priority=10)
??:??:?? 30 [NodeInfoPlugin] SimRadio.send
??:??:?? 30 [NodeInfoPlugin] FIXME-update-db Sniffing packet
??:??:?? 30 [NodeInfoPlugin] Delivering rx packet (id=0x5851f430 Fr0x5f To0xff, WantAck0, HopLim3 Portnum=4 WANTRESP priority=10)
Trigger powerFSM 3
                  ??:??:?? 30 [NodeInfoPlugin] Forwarding to phone (id=0x5851f430 Fr0x5f To0xff, WantAck0, HopLim3 Portnum=4 WANTRESP priority=10)
??:??:?? 30 [NodeInfoPlugin] Update DB node 0xe31bc5f, rx_time=0
??:??:?? 30 [NodeInfoPlugin] Received nodeinfo from=0xe31bc5f, id=0x5851f430, payloadlen=38
??:??:?? 30 [NodeInfoPlugin] old user !0e31bc5f/Unknown bc5f/?5F
??:??:?? 30 [NodeInfoPlugin] updating changed=0 user !0e31bc5f/Unknown bc5f/?5F
??:??:?? 30 [NodeInfoPlugin] sending owner !0e31bc5f/Unknown bc5f/?5F
??:??:?? 30 [NodeInfoPlugin] Sending response
??:??:?? 30 [NodeInfoPlugin] Update DB node 0xe31bc5f, rx_time=0
??:??:?? 30 [NodeInfoPlugin] Received nodeinfo from=0xe31bc5f, id=0x5851f432, payloadlen=38
??:??:?? 30 [NodeInfoPlugin] old user !0e31bc5f/Unknown bc5f/?5F
??:??:?? 30 [NodeInfoPlugin] updating changed=0 user !0e31bc5f/Unknown bc5f/?5F
??:??:?? 30 [NodeInfoPlugin] Plugin nodeinfo handled=0
??:??:?? 30 [NodeInfoPlugin] Enqueuing local (id=0x5851f432 Fr0x5f To0x5f, WantAck0, HopLim3 Portnum=4)
??:??:?? 30 [NodeInfoPlugin] Plugin nodeinfo handled=0
??:??:?? 30 [NodeInfoPlugin] Adding packet record (id=0x5851f430 Fr0x5f To0xff, WantAck0, HopLim3 Portnum=4 WANTRESP priority=10)
??:??:?? 30 [NodeInfoPlugin] SimRadio.send
??:??:?? 30 (Client not yet interested in packets)
??:??:?? 30 (Client not yet interested in packets)
??:??:?? 30 [Router] Adding packet record (id=0x5851f431 Fr0x5f To0x5f, WantAck0, HopLim3 Portnum=4)
??:??:?? 30 [Router] FIXME not implemented addRoute
??:??:?? 30 [Router] FIXME-update-db Sniffing packet
??:??:?? 30 [Router] Delivering rx packet (id=0x5851f431 Fr0x5f To0x5f, WantAck0, HopLim3 Portnum=4)
Trigger powerFSM 3
                  ??:??:?? 30 [Router] Forwarding to phone (id=0x5851f431 Fr0x5f To0x5f, WantAck0, HopLim3 Portnum=4)
??:??:?? 30 [Router] Update DB node 0xe31bc5f, rx_time=0
??:??:?? 30 [Router] Received nodeinfo from=0xe31bc5f, id=0x5851f431, payloadlen=38
??:??:?? 30 [Router] old user !0e31bc5f/Unknown bc5f/?5F
??:??:?? 30 [Router] updating changed=0 user !0e31bc5f/Unknown bc5f/?5F
??:??:?? 30 [Router] Plugin nodeinfo handled=0
??:??:?? 30 [Router] Adding packet record (id=0x5851f432 Fr0x5f To0x5f, WantAck0, HopLim3 Portnum=4)
??:??:?? 30 [Router] FIXME not implemented addRoute
??:??:?? 30 [Router] FIXME-update-db Sniffing packet
??:??:?? 30 [Router] Delivering rx packet (id=0x5851f432 Fr0x5f To0x5f, WantAck0, HopLim3 Portnum=4)
Trigger powerFSM 3
                  ??:??:?? 30 [Router] Forwarding to phone (id=0x5851f432 Fr0x5f To0x5f, WantAck0, HopLim3 Portnum=4)
??:??:?? 30 [Router] Update DB node 0xe31bc5f, rx_time=0
??:??:?? 30 [Router] Received nodeinfo from=0xe31bc5f, id=0x5851f432, payloadlen=38
??:??:?? 30 [Router] old user !0e31bc5f/Unknown bc5f/?5F
??:??:?? 30 [Router] updating changed=0 user !0e31bc5f/Unknown bc5f/?5F
??:??:?? 30 [Router] Plugin nodeinfo handled=0
??:??:?? 30 [Screen] Screen: Joined: Unknown bc5f
??:??:?? 30 [Screen] Screen: Joined: Unknown bc5f
??:??:?? 30 (Client not yet interested in packets)
??:??:?? 30 (Client not yet interested in packets)

I would say this all looks good. I can switch screens with the button(s? both buttons do the same). I’m not getting anything from the Android app though. There’s only “None” in the list of radios.

1 Like

Not sure what changed but while messing around with it, I now have a connection to my phone:

??:??:?? 115 toRadioWriteCb data 0x2000ea18, len 32
Trigger powerFSM 9
                  ??:??:?? 115 PACKET FROM PHONE (id=0x30534d1c Fr0x5f To0xff, WantAck1, HopLim0 Portnum=1)
??:??:?? 115 Update DB node 0xe31bc5f, rx_time=0
??:??:?? 115 Received text msg from=0xe31bc5f, id=810765596, msg=yep
Trigger powerFSM 5
                  ??:??:?? 115 showing standard frames
??:??:?? 115 Showing 0 plugin frames
??:??:?? 115 Total frame count: 35
??:??:?? 115 Added plugins.  numframes: 0
??:??:?? 115 Finished building frames. numframes: 3
??:??:?? 115 Setting fast framerate
??:??:?? 115 Plugin text handled=0
??:??:?? 115 FIXME not implemented addRoute
??:??:?? 115 FIXME-update-db Sniffing packet
??:??:?? 115 Delivering rx packet (id=0x30534d1c Fr0x5f To0xff, WantAck1, HopLim0 Portnum=1)
Trigger powerFSM 3
                  ??:??:?? 115 [Screen] Forwarding to phone (id=0x30534d1c Fr0x5f To0xff, WantAck1, HopLim0 Portnum=1)
??:??:?? 115 [Screen] Update DB node 0xe31bc5f, rx_time=0
??:??:?? 115 [Screen] Received text msg from=0xe31bc5f, id=810765596, msg=yep
Trigger powerFSM 5
                  ??:??:?? 115 [Screen] showing standard frames
??:??:?? 115 [Screen] Showing 0 plugin frames
??:??:?? 115 [Screen] Total frame count: 35
??:??:?? 115 [Screen] Added plugins.  numframes: 0
??:??:?? 115 [Screen] Finished building frames. numframes: 3
??:??:?? 115 [Screen] Setting fast framerate
??:??:?? 115 [Screen] Plugin text handled=0
??:??:?? 115 [Screen] Adding packet record (id=0x30534d1c Fr0x5f To0xff, WantAck1, HopLim1 Portnum=1)
??:??:?? 115 [Screen] SimRadio.send
??:??:?? 115 [Screen] Setting idle framerate
??:??:?? 115 (Client not yet interested in packets)
??:??:?? 115 Telling client we have new packets 9
??:??:?? 115 BLE notify fromNum
??:??:?? 115 getFromRadio, state=6
??:??:?? 115 phone downloaded packet (id=0x30534d1c Fr0x5f To0xff, WantAck1, HopLim0 Portnum=1)
??:??:?? 115 encoding toPhone packet to phone variant=2, 32 bytes

One thing I know is that if I made my HW_VENDOR string “lifepo4wered-lora”, I got this crash:

??:??:?? 21 encoding toPhone packet to phone variant=3Error: can't encode protobuf unterminated string
??:??:?? 21 assert failed src/mesh/mesh-pb-constants.cpp: 22, size_t pb_encode_to_bytes(uint8_t*, size_t, 
const pb_msgdesc_t*, const void*)??:??:?? 0 Emitting reboot packet for serial shell

I assume I went over some length limit with that name. I now changed it to “lfp-lora” and that crash went away.

Now I just need to figure out why the SPI to the real LoRa module doesn’t work.

3 Likes

Very cool.

I’m interested in ordering some boards when you have them ready.

2 Likes

yep: that’s what that assertion means. I’ll make the panic message clearer. That limit comes from:

*MyNodeInfo.hw_model max_size:16

in mesh.options. You almost got lucky enough that your first choice was short enough. :smile:

I assume this is something common between platforms and app and can’t be changed for a particular board? I tend to run into problems with name fields being too short all the time (seeing how long my own name is). :wink:

1 Like

I had ordered some parts that I now received and I thought I’d share this:

Look how small that nRF52840 based E73 module laying on top is compared to the nRF52832 based E73 below it!

That leaves extra room… maybe for something like that cute little GNSS module? :wink:

Meanwhile, I still need to get back to trying to make the current hardware work. My current theory is that “something” (bootloader maybe) sets one of the pins I intended to use for SPI up for another use so the SPI to the E22 LoRa doesn’t work.

2 Likes

That’s awesome!

Re spi
My next step would be to somehow bite the bullet and tack solder some blue wires to the four spi lines so you can see them on a logic analyzer. Then it should be easy to see which are jiggling when we try to talk to the radio.

Super cool board.

Right. I just have to find time to get back to it…

One problem I had to overcome when doing my own nrf52 port was to #define SX1262_CS to whatever you SPI NSS pin is connected. Not sure if this is your your problem as well, but maybe this will help.

1 Like

@vfurman thanks for sharing that, I already seem to have that defined correctly though.

1 Like

Why didn’t you design this board to be double-sided?
It could be reduced in size

@Xanuman the board is kind of “pad limited” as it is, meaning I’d have to reduce available I/O to make it smaller. Or go to a double row header. The way it is, it works either with a header or as an SMT module with castellated edges. Going to double row I/O or two sided components would remove that possibility.

It is also designed to work with an on-board 14500 size LiFePO4 or LTO cell. Going smaller is not necessarily useful if the overall size of the system is dictated by the fact it needs a battery, as is the case here.

Others have also commented they like the single header row and how it works with a breadboard, as shown in one of the pictures posted above. I guess it’s not possible to please everyone? :man_shrugging:

2 Likes

I finally got it to work! :slight_smile:

As suspected, P0.21 was somehow locked into RESET function, by the bootloader I presume, which made the SPI bus fail when I attempted to use it as SCLK.

I finally managed to modify one of my boards to move the SCLK to another pin:

It took some kapton tape, better soldering skills and eyesight than I have, but I got it sort of done. After that the SX1262 initialized correctly!

??:??:?? 0 Starting meshradio init...
??:??:?? 0 (bw=125, sf=12, cr=4/8) packet symLen=32 ms, payloadSize=16, time 2269 ms
??:??:?? 0 Set radio: name=LongSlow, config=3, ch=0, power=0
??:??:?? 0 Radio myRegion->freq: 903.080017
??:??:?? 0 Radio myRegion->spacing: 2.160000
??:??:?? 0 Radio myRegion->numChannels: 13
??:??:?? 0 Radio channel_num: 0
??:??:?? 0 Radio frequency: 903.080017
??:??:?? 0 Short packet time: 2269 msec
??:??:?? 0 Set radio: final power level=22
??:??:?? 0 SX1262 init result 0
??:??:?? 0 Radio init succeeded, using SX1262 radio

After that it managed to talk with a T-BEAM:

4 Likes

Actually the above was a little simplified. I first had to update my firmware from upstream before the app would talk to it. Isn’t that a bit of a problem for a system like this? I mean, maybe people can keep devices they carry around updated all the time so it will still work when their phone updates their app, but how about fixed nodes? Do they become useless? Or is the idea that people don’t directly connect to them anyway and they will continue to happily pass LoRa messages on for more up-to-date nodes?

@geeksville I also had to disable the call to initBrownout in main-nrf52.cpp to make it work. Otherwise it would keep failing the assert for the sd_power_pof_enable call. The error code was 2, which led me to this: https://devzone.nordicsemi.com/f/nordic-q-a/25530/calling-sd_power_pof_enable-error-code-2

It seems code 2 is NRF_ERROR_SOFTDEVICE_NOT_ENABLED. It seems the solution according to that post is to call sd_softdevice_enable, but I couldn’t find any call to that in the code.

I was also a bit curious why you are setting the brownout level to 2.7V (or 2.8V, I see both in the code?). I specifically designed this board with the nRF52 because it can work down to 1.7V, which is great when powering it from an LTO (Lithium Titanate) cell. Setting the brownout this high defeats that and will only make it work with LiFePO4.

1 Like

I’m hiking until this evening but will reply to your great post then.

I had the same issue with SD not enabled when initBrownout() is called (and the same issue with getMacAddress()). I suspect the Adafruit BT library calls sd_enable, but this happens later in the execution. Never got to really solving it…

Within a major release tree (i.e. 1.2.x) all of the messages/protocol is supposed to stay “wire compatible” on the mesh. So for physically inaccessible router nodes, you only need to update them if you need some particular new bugfix or feature that is relevant to that node. They should happily route other 1.2.x packets (perhaps not optimally) for other nodes of whatever vintage.

We normally get the soft-device enabled only once we turn-on bluetooth. This behavior is controlled by “useSoftDevice” in main-nrf52.cpp. I’ve been kinda sloppy about leaving that flag false sometimes in master, because we don’t yet have an “off the shelf” nrf52 board that users can buy (I think ttgo “T-Echo” (the official name for their eink board) is close), and within the next couple of weeks I’m going to add the RAK wireless board to the standard bin releases.

Much of the (usually excellent) ICE debugger support on the NRF52 has to be disabled when bluetooth is enabled, which is why I often turn off bluetooth while using the debugger.

Possibly I messed up on the brownout init for the case where we didn’t have soft-device running. Any pull request would be appreciated.

Heh! This was because I was trying to debug a power problem in “yet another” NRF52 board. You are correct - lowering the brownout threshold to the lowest allowed would be smart. If could could send in a pull request for this I would happily merge it.

Your board sounds like it is going great! Congrats!

@geeksville I’d love to send a PR, if only I knew what I was doing. :wink:

I went into embedded systems because I hated dealing with bloated frameworks, dependencies, and the black magic that goes on inside them so you’re always at the mercy of all these things, their bugs, side effects, and how they may change at any given time. Embedded software used to be fully under your own control, no magic going on in the background, and I like that. As time goes on, embedded software is becoming just as bad as any other software development as CS “best practices” (haha) start to trickle down to larger micros.

Unfortunately, while the nRF52 is great hardware, from a software point of view it’s about as bad as it gets in that respect with both the softdevice and bootloader and all their associated magic. Which is why I was looking at existing pieces of software that could support this board, and Meshtastic looked like a great candidate. As I’ve gotten more involved it looks like it’s still a work in progress compared to the ESP32 version. That’s OK though, I don’t mind putting in a bit of time to help the project along, but I’m not sure how much use I can be without breaking something.

Looking at the initBrownout function:

void initBrownout()
{
    auto vccthresh = POWER_POFCON_THRESHOLD_V28;

    if (useSoftDevice) {
        auto err_code = sd_power_pof_enable(POWER_POFCON_POF_Enabled);
        assert(err_code == NRF_SUCCESS);

        err_code = sd_power_pof_threshold_set(vccthresh);
        assert(err_code == NRF_SUCCESS);
    } else {
        uint32_t pof_flags = POWER_POFCON_POF_Enabled | (vccthresh << POWER_POFCON_THRESHOLD_Pos);

#ifdef POWER_POFCON_THRESHOLDVDDH_Msk
        auto vcchthresh = POWER_POFCON_THRESHOLDVDDH_V27;
        pof_flags |= (vcchthresh << POWER_POFCON_THRESHOLDVDDH_Pos);
#endif

        NRF_POWER->POFCON = pof_flags;
    }
}

So it looks like there’s a check to see whether useSoftDevice is set. If it is, you use softdevice calls to set the brownout level, otherwise you directly write to a register to do the same. My code would hang on the first assert. This is odd, since it’s within the useSoftDevice check. It’s like this code is run before the soft device is enabled.

Now, being a “set the register” kind of guy, my first question is: is there a point to having two different ways to do this (one with softdevice calls and one writing the register)? Can’t this just be done by setting the register even if softdevice is active? Then it wouldn’t matter whether the softdevice was already enabled by the time this is called or not.

I changed the code to this:

void initBrownout()
{
    auto vccthresh = POWER_POFCON_THRESHOLD_V17;
    uint32_t pof_flags = POWER_POFCON_POF_Enabled | (vccthresh << POWER_POFCON_THRESHOLD_Pos);

#ifdef POWER_POFCON_THRESHOLDVDDH_Msk
    auto vcchthresh = POWER_POFCON_THRESHOLDVDDH_V27;
    pof_flags |= (vcchthresh << POWER_POFCON_THRESHOLDVDDH_Pos);
#endif

    NRF_POWER->POFCON = pof_flags;
}

It seems to be doing the correct thing on my board, I can observe the correct value in the POFCON register when the system is running so it doesn’t seem like the softdevice is messing with it after it gets set.

1 Like