Difference between revisions of "BoSL Board nano"
Line 334: | Line 334: | ||
== USB device not recognized == | == USB device not recognized == | ||
− | Seen this | + | Seen this repeatedly happen on one Nano board, reboot computer not help<br> |
− | Q: What's the cause? How to fix | + | Q: What's the cause? How to avoid or fix this? |
== Voltage issue == | == Voltage issue == | ||
Two Nano boards were test unusually voltage, when connect to battery power(full charged), Vpp pin 0.38V and 3.3V pin 0.33V. | Two Nano boards were test unusually voltage, when connect to battery power(full charged), Vpp pin 0.38V and 3.3V pin 0.33V. | ||
When connect to power via USB, Vpp and 3.3V are all good. | When connect to power via USB, Vpp and 3.3V are all good. |
Revision as of 07:43, 10 August 2023
The BoSL nano will be a more feature enabled version of the BoSL micro while still retaining the small form factor.
Key changes from the BoSL:
- Upgrade SIM7000 to smaller nRF9160
- Remove much of the connectivity to achieve smaller profile
- Add NFC
- Make board much smaller. No more than 15 mm in width.
- Removed MS5803
A number of new components will be used in this design.
The MCU will be the SAMD21G18. The modem used will be the nRF9160. It will also incorporate NFC. The connectivity will expose 7 analog pins and 10 digital pins as well as several power pins and an I2C interface. A diode O-ring similar to that on the microBoSL utilizing the MAX40203ANS will be incorperated so that the device may be powered either via USB or battery supply.
Its maximum dimensions are to be no wider than 15mm.
The architecture of this board will be similar to the main BoSL board. We will use the SAMD21G as the main processor and the nRF9160 as our LTE modem.
Contents
- 1 Programming
- 2 Development Log
- 2.1 18th Decemeber 2020
- 2.2 20 May 2021
- 2.3 12 July 2021
- 2.4 13 July 2021
- 2.5 15 July 2021
- 2.6 16 July 2021
- 2.7 19 July 2021
- 2.8 22 July 2021
- 2.9 24 July 2021
- 2.10 5 August 2021
- 2.11 23 September 2021
- 2.12 7th October 2021
- 2.13 24th November 2021
- 2.14 2nd December 2021
- 2.15 6th December 2021
- 2.16 21st January 2022
- 2.17 15th February 2022
- 2.18 14 March 2022
- 2.19 4 April 2022
- 2.20 7th April 2022
- 2.21 23rd June 2022
- 2.22 18th November 2022
- 2.23 8th December 2022
- 2.24 20th December 2022
- 3 Other known issues
Programming
Here we provide instructions to burn firmware to the BoSL nano.
There are two ICs on the BoSL nano which need firmware to operate. The SAMD21G18A and the nRF9160. The SAMD21G18A is the main microcontroller and the nRF9160 is the modem. Normally the nRF9160 will only need firmware uploaded once performed either at the factory or before first use. Once the modem firmware is flashed there shouldn't be any need to change this. The SAMD21G18A's firmware is what is flashed when uploading from the Arduino IDE. To facilitate this a bootloader needs to first be flashed either at the factory or before first use.
Please find the instructions for 1. flashing the bootloader, 2. uploading from the Arduino IDE, and 3. flashing the nRF9160.
A set of firmwares can be downloaded from the Design_Library under the firmware column.
1. flashing the bootloader
To flash the bootloader you will need a segger j-link debug probe and a computer with the segger j-link software tools installed.
- Plug the BoSLnano into the computer via USB.
- Plug in the Segger J-link into the computer and open the J-Flash or J-Flash Lite tool if programming for development purposes ([1]). We will taylor instructions for the J-flash lite tool.
- Select the options as per the diagram in the gallery. Click Ok.
- Under the Data File open the firmware "samd21_sam_ba_bosl_nano.hex" file.
- Follow the wiring diagram in the gallery to connect the BoSL nano to the J-link probe. A pinout for the J-link for SWD can be found in its instruction manual [2]. The depicted programmer probe may also be found useful for making contact with the pads on the BoSLnano, the pins are spring loaded so push down slightly with the probe to make good contact.
- Click the program device button in the J-flash window. If the tool indicates that an error has occurred. Check your wiring and then check it again.
2. uploading from the Arduino IDE
- Plug the BoSL nano into the computer via USB
- Open the script you wish to upload in the Arduino IDE
- If you have already installed the BoSLnano board skip to step 8.
- In the Arduino IDE navigate to File->Preferences
- Under Additional Boards Manager URLs: add "https://monash-bosl.github.io/BoSL-IDE-Core/package_bosl.com.au_index.json"
- Navigate to Tools->Board:->Boards Manager
- Search for the "BoSL SAMD Boards" package and install the latest version
- Navigate to Tools->Board: and search and select the "BoSL nano" board
- Still under Tools select the correct port for the BoSL nano, the tools menu should now look similar to that in the gallery.
- Click the upload button
- If this process fails one thing to try is to put the BoSL nano in bootloader mode. This can be done by double clicking the reset button until the U (upload) LED is breathing. Selecting this port from the tools menu and then clicking upload, or clicking upload and then entering into bootloader mode while the upload script is searching for an upload port can both be tried until a successful upload is achieved.
3. flashing the nRF9160
To flash the bootloader you will need a segger j-link debug probe and a computer with the segger j-link software tools installed.
- Plug the BoSLnano into the computer via USB.
- Plug in the Segger J-link into the computer and open the J-Flash or J-Flash Lite tool if programming for development purposes ([3]). We will taylor instructions for the J-flash lite tool.
- Select the options as per the diagram in the gallery. Click Ok.
- Under the Data File open the firmware "bosl_nano_nrf9160_firmware_x.x.x.hex" file.
- Follow the wiring diagram in the gallery to connect the BoSL nano to the J-link probe. A pinout for the J-link for SWD can be found in its instruction manual [4]. The depicted programmer probe may also be found useful for making contact with the pads on the BoSLnano, the pins are spring loaded so push down slightly with the probe to make good contact.
- Click the program device button in the J-flash window. If the tool indicates that an error has occurred. Check your wiring and then check it again.
Writing your sketch
The sketch for the samd21/BoSLnano can be written as per any other arduino sketch. Some hardware specific details are dot pointed below:
- The Serial object is for talking over the USB virtual COM port
- The Serial1 object is for talking with the nRF9160 Modem the nRF1960 is expecting baud 115200.
- The Serial2 object is a serial port on A6,A5. Serial3 object is a serial port on D0,D1 (available in firmware release 1.1.0+)
- The digital pin nRF_EN needs to be drawn high to enable the nRF9160 modem
- The digital pin nRF_RST can be used to reset the nRF9160
- The digital pin nRF_SW_EN can be used to wake the nRF9160 from sleep when drawn low and back high
- The analogue pin ADC_BATTERY can be used to monitor the battery level (consider the connected voltage divider)
- The digital pin VNFC can be used to turn on and off the NFC chip
- The digital pin NFC_I can be used as an interrupt pin from the NFC chip
- The ArduinoLowPower library is recommended for low power sleep along with sending the AT command AT#XSLEEP=1 to the nRF9160
- A complete list of AT commands for the nRF9160 can be found at [5]
A starter script for simple datalogging and uploading is provided: File:SimpleLogger.ino
LTE Connection
The default settings found in the logging scripts should work well for use in Australia. International use is currently untested and requires some tweaking. If you are using a carrier SIM, once the APN is changed connection connect should be automatic. If you are using an IoT SIM, the APN does not need to be changed, but the preferred network will be. If no preferred network is selected each time the nRF9160 attempts to connect to a network it will first perform a scan of all available network. This is lengthy and wastes time. To select a network the AT command manual lists the command:
AT+COPS=1,2,"MCCMNC"
Where the MCC MNC identity the network. For Telstra MCC is 505 and the MNC is 01 so the AT command reads:
AT+COPS=1,2,"50501"
To obtain a list of current networks use
AT+COPS=?
This command may take a number of minutes to run. Alternatively you can scans current available networks on your phone. Refer to your phone's manual for device specific instructions. A list of MCC and MNC codes may also be found at [6].
Once you are connected to a network you need to determine if the SIM is connected as a home network or roaming. Use AT command:
AT+CEREG?
With example response:
+CEREG: 2,x,"002F","0012BEEF",7
Where x = 1 for home network connection and x = 5 for roaming. In the code, the response of the AT+CEREG command is used to check connectivity status. You will need to change the expected response string to be 1 or 5 to match the your setup.
MQTT
A lightweight datalogging setup is MQTT, details on how to set this up with the BoSLnano can be found at MQTT
PSM & eDRX
With the SIM7000 we often resorted to AT+CFUN=0 to turn on and off the LTE connection. With the nrf9160 we can activate power saving modes where the modem stays connected to the network but in a very low power state. When it wakes up there is no need to turn on the cellular modem or register to the network so the total logging time can be reduces from 10s of seconds to single seconds. To activate PSM and eDRX I have been using the following commands:\
AT+CPSMS=1,"","","00000110","00000000" AT+CEDRXS=1
The two strings in the PSM command Periodic TAU and Active Time and relate to how often the device needs to ping the cell tower when in sleep. Please refer to the AT command manual for specific advice on these values.
Development Log
18th Decemeber 2020
The first question on using the SAMD21G and the nRF9160 is a question of how these will be programmed. The boot-loader for the SAMD21G will be the Arduino MRK Zero board. This is because it has a built in SD card interface and generally is the most similar to the design. The nRF9160 will be connected via UART on the hardware serial interface. Also after the NFC chip this leaves 14 I/O pins free for end user application. The split is 7 analog and 7 digital pins, all are capable of interrupts.
The SAMD21G bootloader can be installed via a SWD interface and relevant programmer. These pins will be exposed. There are multiple programmers available on the market, a specific one has not been decided yet.
20 May 2021
We have made a mistake in the manufacturing the switch SW1 has 4 terminals and our footprint shorts it out.
12 July 2021
The boot-loader was able to be uploaded to the SAMD and after this programs could be uploaded via the arduino IDE and USB. The following steps were used to compile and upload the bootloader. The process was mostly straightforward however various packages and tools were needed to be installed to compile the bootloader.
Simple functions were then verified like RTC and analog reading. These were all working normally.
Some work was done to fixed up the boot loader and board definitions to match the circuit of the BoSL nano. These new definitions will be made available to download at a future time.
13 July 2021
These board definitions were finished and packaged up as a board in the arduino IDE board manager. Some of the custom pin functions were given specific names under the board. This includes, VNFC, for the nfc voltage. A full list will be documented soon. The used bootloader is also included in this package.
The current consumption was measured on a blank script. This was measured at 65 mA. Which is quite high, however the nRF9160 has not been flashed with any firmware yet so it is likely to be in some idle state. Placing the SAMD21 in sleep mode reduces the current consumption to 35 mA.
15 July 2021
It was found pull-up resistors were needed to be added to get the I2C bus to function. These should be included in the next revision. The nRESET resistor on nrf9160 should also be removed as it is not recommended in the datasheet.
16 July 2021
The process to get the nRF9160 to work has been a bit more complicated than desired. The Nordic SDK was needed to be installed. From this example applications could be built from the command line and then flashed with the J-link and Nordic flash utility. The SDK requires each a definition of the configuration of each board. I have copied the board definition for the nRF9160 development kit, and relabeled it for the BoSL nano. This definition can be used ot define where the USART interface goes and all that. I am still learning how these definitions work. So far I have been able to build the zephyr/blinky example to get the onboard LEDs to blink. Most of this learning has been following the nordic SDK documentation.
I was then able to get USART to work via editing the usart device definitions in the zephyr board configutation. After this the serial LTE modem firmware was attempted to be run. This once built on the non-secure built option. And with build configuration of uart2 (which had the correct pin-out and with hardware flow control disabled via commenting out in the bosl_nanons.overlay file in the source directory) it was able to be used with a serial pass through application developed on the SAMD. The module was now responding to AT commands. Following the AT command manual the GPS was tested and found to be working. The performance was quite good with a time for first fix (TFF) of 131s while indoors. The current BoSL board cannot get a gnss fix while indoors most of the time and often has a TFF of several minutes. The bosl nano has passed this large milestone, and looks to be largely functional. Will be on finialising a version of the AT client with extra features such as LED debug.
19 July 2021
A detailed description of how to setup an environment to build the nRF9160 firmware is described here
22 July 2021
The BoSL nano was able to upload to the testing server over LTE. Once registered to the network this was achieved with the following command chain.
AT#XHTTPCCON=1,"www.bosl.com.au",80
Which connects to the bosl server over http, and then in brief succession the command:
AT#XHTTPCREQ="GET","/IoT/testing/scripts/WriteMe.php?SiteName=BoSLnano.csv&T=1",""
which sends the get request for the given resource. Where the site name and variables are changed according to need.
24 July 2021
Attached a script which intermittently logs to the bosl server File:SimpleNanoLogger.ino. The data to be uploaded can be inserted by updating the uploadATsequence function. One caveat is that every time the board sleeps the USB serial port gets disconnected. Hence it needs to be reopened after every waking, otherwise no Serial data will appear. To get the BoSLnano board add:
https://monash-bosl.github.io/BoSL-IDE-Core/package_bosl.com.au_index.json
to the additional board url box in File->Preferences menu of the Arduino IDE. The BoSL SAMD boards can then be downloaded from the board manager and the BoSLnano can then be selected as the board target in the tools menu.
5 August 2021
It is necessary to find a power state where minimal power is used. To find this a number of scripts were run on the BoSL nano and then the total board power consumption was measured. In these tests the board was powered via the battery port at a voltage of 4.2V. The results are indicated below.
1. delay() | 60.0 mA
2. uart on, nRF_EN output high, AT#XSLEEP=2, delay() | 60.4 mA
3. uart on, nRF_EN output high, AT#XSLEEP=2, nRF_EN output low, delay() | 65.9 mA
4. uart on, nRF_EN output high, delay() | 62.3 mA
5. LowPower.deepSleep(); | 31.2 mA
6. LowPower.deepSleep(); PinMode(input); (on connected pins) | 31.2 mA
In reading the nrf9160 documentation VDD_GPIO should be driven low when ENABLE is drive low, this is not currently done.
I tried to setup another BoSLnano to see if it also had this current issue. However this BoSLnano had a constant short circuit when power was supplied by either USB or the battery port. Additionally one side of the nRF9160 got very hot when powered up. It is assumed that either the soldering is bad or the nRF9160 is bad. Given the tight tolerances of the PCB, an issue with the soldering is possible. This could be investigated by de-soldering components one at a time and seeing if the issue resolves itself. It is also possible that a similar soldering issue is the cause of the high current in the current draw tests.
23 September 2021
In order to figure out how why this current was so high, I have de-soldered the RF-circuitry and nRF9160 on the short circuit BoSL board. Once this was done the short circuit disappeared. Some notes
- With the nRF removed I was getting similar power figures to the working BoSL nano indicating that the nRF is not the source of the current draw. Either the ATmega or some other peripheral.
- Progressively to diagnose the issue more parts were removed but the current consumption still remained (much 30 mA vs 12 mA) higher than the arduino MKRzero based on the same ATSAMD21G.
- I swapped the chips between the MKRzero and the BoSL nano however the current consumption still remained at 30 mA.
- All the parts were removed apart from the crystal, 2 crystal capacitors, 1 SAMD21G decoupling capacitor, and the SAMD21G, yet the power consumption was still at 30 mA
Specifically the current consumption was 30mA in sleep mode and 50mA while running delay() code. This data leaves the following conclusions
1) The wrong firmware is loaded
2) The crystal is causing the current draw
3) There is a manufacturing fault (partial short etc...)
Of these hypothesis, 1) seems unlikely as the same SAMD21G was running at 12 mA in delay() and ~0 mA in sleep when connected to the MKRzero. 2) is possible however i've never seen a crystal change the current consumption that much. This leaves 3) which is I suspect the most likely reason of this behavior. Perhaps there is a via partially shorting two pins as the spacing in many places is very tight. If this is the issue it would have to be systemic to the design as both PCB's seemed to have this issue.
7th October 2021
To find out why this 30 mA current draw was occuring, I have laid out a quick version of the BoSL nano where all the components are spaced for easy diagnostic access. In addition to this the pins of the micro-controllers are all connected through solder-able jumpers. This allows PCB connections to be removed and remade quickly while diagnosing any errors. A render of the PCB is provided below:
24th November 2021
The development PCB's have arrived:
Time to build one up and start testing!
2nd December 2021
As with the last BoSL nano there were issues with power consumption in sleep mode, on the dev board we will slowly add components one by one to measure their power consumption.
Below is a table of the component added and the resultant power consumption.
Component | Current (mA) |
---|---|
SAMD | 32 mA |
After a few minutes the current jumped up to a few hundred milliamperes. After doing another double check of the schematic is was found what the issue was. pin 43 on the SAMD, VDDCORE was connected to 3.3V. This was incorrect as VDDCORE is actually a 1.2V output from the internal regulator. I suspect that applying 3.3V has been killing the internal regulator which powers the CPU and causing our general issues with the device. Having disconnected VDDCORE from 3.3V, the SAMD21G now only draws 4mA, closer to the expected.
I've been unable to get the Segger J-Link connected to the SAMD. I suspect that the issue is with my soldering, I don't have solder paste and wetting the pads with solder wire doesn't work very well. Nevermind, I hadn't yet soldered on the decoupling capacitors between 3.3V and GND on the board, just the SAMD. Once I did this I was able to connect to the SAMD and get it up and running.
An error was noted with the BoSL SAMD package. It does not install the gcc arm eabi none compiler. This is only installed once the Arduino SAMD boards are installed. I'll need to look into how I can make the package auto-grab this.
The USB port was soldered on and now the nano is working with the Arduino IDE. A simple low power script was uploaded to the nano in sleep mode it has a power consumption of 350μA.
The MAX40203 ideal diodes which control the power source were not able to be soldered due to their small size, the regulator however was and was found to be in working order.
After re-soldering the nRF9160, this too worked and was able to be connected to with the J-link.
In summary the key change needed to fix the BoSL nano, was that VDDCORE mustn't be connected to 3.3V.
6th December 2021
Changes were made to the BoSL nano design to fix the issues had these included:
- disconnecting VDDCORE from 3.3V
- increasing the spacing between the programming pads to 1.27 mm
- the reset switch footprint was fixed
- 10 kΩ pullup resistors were added to the I2C bus
- nRF9160 nRESET pin now does not have the pullup resistor populated by default as per the datasheet.
- misc bom changes for out of stock parts
The design files can be found here: and here:
21st January 2022
The rev 0.2.0 D1 footprint is too small for the selected part. This issue should only affect the usb detection, so isn't considered critical.
15th February 2022
The first batch of BoSL nanos arrived today:
We will be testing them out to verify that the changes made since the previous prototype were working. It seems they do not have any programs flashed to them yet, however do have their bootloader flashed. If they are plug into the computer via usb they can be programmed using the arduino IDE. It seems that the site package for arm g++ is not fetched by the current board definition in the Arduino IDE. I have updated the board definitions in the 1.0.6 release to newer versions of the toolchain and updated the paths which link to these tools to act correctly.
I am now going to document the process I used to get the nrf9160 firmware built. I am following the guide found at: https://devzone.nordicsemi.com/guides/nrf-connect-sdk-guides/b/getting-started/posts/nrf-connect-sdk-tutorial---part-1-ncs-v1-4-0#h769sk6kqovea15p99jn16lstat1dtpuuw in particular the build and flash using west section. I prefer to use command line tools for this as they tend to be more repeatable. The toolchain was installed through the nrf for desktop toolchain manager. After this the bosl nano board definition was added in the ncs\v1.8.0\zephyr\boards\arm directory. The serial LTE application with modifications for the BoSL nano can now be built using west. The merged.hex file in the build and zephyr subdirectories could then be flashed onto the nrf9160 via SWD, the SAMD on the BoSL nano is now able to talk to the nRF9160 through AT commands.
For reference and safekeeping here is a working firmware for the nrf9160: File:Nrf9160 nano firmware.zip
14 March 2022
The nrf9160 firmware was modified to enable the functioning of the status LEDs. The current behaviour of the status LEDs is as follows. When plugged in to USB power, the "M" LED will be on whenever the modem is not in sleep mode. The "S" LED will blink whenever the modem has it's cellular radio turned on. This firmware is suppled here File:Bosl nano nrf9160 firmware 1.0.0.hex.zip
4 April 2022
A long term logging test was set up with the BoSL nano. This was done to both test the low power performance of the BoSL nano and also verify that the firmware is working stably. The entire testing setup was placed in a BoSL box and then left to log on a shelf. The setup is logging the battery voltage, number of logs, and any error codes which come up.
7th April 2022
A minor issue was found with the BoSL nano battery voltage measurement, the current resistor arrangement only allows for a maximum measurable voltage of 4.217 V. This should be increased a bit in future revisions.
23rd June 2022
The results of the long term BoSL nano logging test are in. The BoSL board survived for a total of 54 days at a 1 minute logging interval on a 11200 mAh battery. This equated to a total of 68877 logs. One issue found was that half way through the test the Board stopped logging and needed to be reset. After the reset, 36 hours after logging stopped, battery voltage had dropped 140 mV. The remainder of the test ran smoothly. This issue will need to be investigated further find its cause. Another issue was found all AT#XHTTPCREG commands should be sent with third parameter "\r\n" for <headers>. Otherwise the modem still connects to the website however it returns an error. Making this change deceases the logging time by 3 seconds, or about half.
18th November 2022
There was interest in enabling FTP uploads from the BoSL nano. This seemed like a simple task as the nRF9160 has a set of AT#XFTP commands. These however only work over IPv4. Additionally, for some FTP server the domain name resolution will not work over IPv4 hence no connection will be able to be established. A workaround for the domain name resolution issue is to manually enter the IP address in to the AT#XFTP="open","<username>","<password>","<server address>" command. Additionally the FTP client only is able to work with PASV mode over IPv4 I have modified the ftp_client.c library to only resolve domain names over an IPv4 connection. This means that IPv6 connections will return errors, but they are not able to be used with the FTP server in any case. Specifically the fix was to put the IPv4 domain name resolution code line as the default
8th December 2022
A speed test was just done on the nRF9160. It was found to have a upload and download speed of 168 Kbits/sec or about 21 kB/sec. This should set a benchmark for any data uploading to be performed.
20th December 2022
Some new ideas inspired by large data upload have been thought of. 1. include some flow control between the nRF9160 and SAMD to allow for more reliable data transmission. 2. allow both the nrf9160 and the SAMD to access the SD card for easy and non-synchronous data transfer. It is hoped that these two changes will help with FTP uploading issues in datamode. SLM datamode on FTP upload seem to be a bit fiddly with some bytes being skipped or not transmitted depending on the chucksize and pacing of the dat aset to SLM data mode. It seems, (quite intuitively) that smaller and longer wait period between conformation of reception work better. A configuration which seems to work well is 1024 buffer sized and a 1000 ms delay after the FTP reply code 226.
Other known issues
SAMD21 Flashing Issue
Sometimes it fails many times to upload code to SAMD21. One solution for this is always delay a couple of seconds at the begin of void setup(), it gives us time to flash the code when press reset button.
No Serial Output After Deep Sleep
After called LowPower.deepSleep(int), SAMD21 will close USB(Serial) port before going to sleep.
Q: How to enable the output when MCU wake up?
USB device not recognized
Seen this repeatedly happen on one Nano board, reboot computer not help
Q: What's the cause? How to avoid or fix this?
Voltage issue
Two Nano boards were test unusually voltage, when connect to battery power(full charged), Vpp pin 0.38V and 3.3V pin 0.33V. When connect to power via USB, Vpp and 3.3V are all good.