RAK4630 WisBlock LoRaWAN+BLE Module Firmware Update
There will be situations where you need to update the firmware of your RAK4630. Additionally, there are times when you may want to reload the firmware to ensure everything is properly configured. Updating the firmware of the RAK4630 WisDuo can be done via USB connection or wirelessly using BLE via OTA DFU (Over-the-Air Device Firmware Update). These methods are discussed in this guide.
Prerequisites
What Do You Need?
- nRFutil utility program
- nRF Connect Mobile application
- DFU Distribution Package
- Latest RAK4630 FW DFU Distribution Package
Firmware Update via USB
You need a direct connection to the RAK4630's USB bus before proceeding with the update. Check the minimum schematic in the quick start guide's hardware setup section. This guide covers the three most popular operating systems.
Windows
- Create a new folder in your C:\drive namedRAK4631-R Update.
- Download the  nRFutil.exe and the  latest DFU Package. Once you downloaded both files, put them in the RAK4631-R Updatefolder you created as shown in Figure 1.
 Figure 1: nRFutil.exe and RAK4630 Latest Firmware
Figure 1: nRFutil.exe and RAK4630 Latest Firmware- Connect the RAK4630 via USB and check if the port is detected in Device Manager. In this guide, it is detected as COM32. The COM port number may vary depending on the PC. If no port appears in Device Manager, try double-clicking the reset button and checking again.
 Figure 1: Checking COM Port via Device Manager
Figure 1: Checking COM Port via Device Manager- After that, send the AT+BOOTcommand to the device via serial terminal software. Follow the guide on using Tera Term from the RAK4631-R documentation, but instead of checking the firmware version, inputAT+BOOT. You will see no reply as the module will restart; it will then be momentarily disconnected before re-establishing the connection to Tera Term.
Disconnect teh device from TeraTerm/Serial Terminal software or close it to free the COM port before the firmware update. Otherwise, errors may occur during the update.
Recovery Mode
If AT+BOOT cannot be sent to the device, you can enable DFU mode via the UART2_TX pin. Connect the UART2_TX pin to GND, then reset the device to enter DFU mode.  Proceed to the next step and upload the firmware without the AT+BOOT command.
 Figure 1: AT+BOOT to Initialize Boot Mode
Figure 1: AT+BOOT to Initialize Boot Mode- After initiating Boot mode, execute the firmware update. Open the command prompt and navigate to the RAK4631-R Updatefolder. This folder contains the nRFutil and the latest firmware. Inputcd C:/RAK4631-R Update/followed bynrfutil.exe dfu serial -pkg RAK4631_latest_dfu_package.zip -p COM32. Ensure you have the correct.zipfile name andCOM port numberto avoid errors.
Change the COM port number in the command to match your PC. In this example, it is COM32, but it may differ on your PC.
 Figure 1: FW Update Using nRFutil
Figure 1: FW Update Using nRFutil- Check if the firmware successfully updated using the AT+VER=?command. Follow the guide on using Tera Term from the RAK4631-R documentation to check the firmware version and confirm the device update.
 Figure 1: RAK4631-R Latest Firmware Version Check
Figure 1: RAK4631-R Latest Firmware Version CheckLinux
Setup the Linux Environment
- First, open a new terminal and install all necessary dependencies.
sudo apt-get update
sudo apt-get install net-tools git curl python xclip python3-pip
- Verify that you have installed Python 3.7or later. Check your Python version, as shown in Figure 6.
 Figure 1: Check Python version
Figure 1: Check Python version- Add .localfolder to Linux$PATHvariable.
export PATH="$HOME/.local:$PATH"
- Install nrfutil. It is available as a package in the Python Package Index (PyPI). Execute the following command:
sudo apt-get update
pip3 install nrfutil --user
Setup the Device Console Port in Linux
- Install the minicom using the following commands:
sudo apt-get update
sudo apt-get install minicom
- To open the minicom terminal utility with the ttyACM0 interface. The correct port name can be determined using dmesg, as shown in the next steps.
Enter the following code: minicom -D /dev/ttyACM0
Execute the Firmware Update via USB
- Download the zip file DFU Distribution Package.
When you plug the RAK4630 into a Linux computer via USB, the dmesg command will show the information cdc_acm 1-1:1.0: ttyACM0: USB ACM device
 Figure 1: Checking USB CDC device using dmesg command
Figure 1: Checking USB CDC device using dmesg commandIn this case, the RAK4630 USB CDC device name is /dev/ttyACM0.
- 
Perform the steps described in the section Setup the Device Console Port in Linux. 
- 
On minicom, enter the following AT command: 
AT+BOOT
- Open the terminal and navigate to the directory containing the DFU distribution package. Then, execute the following command:
nrfutil dfu usb-serial -pkg RAK4631_latest_dfu_package.zip -p /dev/ttyACM0
- To check the device's firmware version in the minicom console, enter the following AT command:
AT+VER=?
You should see then the current FW version of the module.
MacOS
- 
Download nrfutil. Usually, the nrfutil-mac.1file will go to the downloads folder. This section assumes any downloaded file goes to the downloads folder.
- 
Open the terminal and navigate to the downloads directory or the location where you saved the downloaded file. Replace usernamewith your actual username;appleis used as an example in this guide.
cd /Users/username/Downloads
- Make the nrfutil-mac.1executable.
chmod +x nrfutil-mac.1
 Figure 1: Download nrfutil for macOS
Figure 1: Download nrfutil for macOS- You also need to determine the RAK4630's port name using the command:
ls /dev/cu.*
 Figure 1: Check the port
Figure 1: Check the port- 
Download the RAK4630 Firmware. Usually, the RAK4631_latest_dfu_package.zipfile will go to the downloads folder.
- 
Open serial terminal software and run the command AT+BOOTto enable the RAK4630's bootloader mode.
AT+BOOT
- Finally, execute the firmware update.
- The nrfutil-mac.1must be in the same folder asRAK4631_latest_dfu_package.zip. In this guide, this is the Downloads folder.
- Ensure you are connected to the correct port. The port name on your computer may differ from the one in this guide.
- The update may take some time. Do not remove the USB or close the terminal application during the upload process.
./nrfutil-mac.1 dfu usb-serial -pkg RAK4631_latest_dfu_package.zip -p /dev/cu.usbmodemC0D048F6604F1
Firmware Update Using BLE via OTA DFU
This section covers how to update your RAK4630 firmware wirelessly via BLE. First, you need to download and install the nRF Connect developed by Nordic Semiconductor. The App is available both in Play Store and App Store.
 Figure 1: nRF Connect App available in Play Store and App Store
Figure 1: nRF Connect App available in Play Store and App StoreDFU OTA Using iOS
OTA DFU Over BLE
- Download the DFU package of the RAK4630 and save it on your mobile phone.
You can upload the Distribution packet (ZIP) file to iCloud Services and then download it to your smartphone.
Make sure Bluetooth on your mobile device is turned on.
- 
Press the reset button and wait a couple of seconds. 
- 
Open the nRF Connect mobile application. You will see all BLE devices in range in the scanner list. 
 Figure 1: Available Bluetooth Devices
Figure 1: Available Bluetooth Devices- Look for a BLE Device named RAK.XXXXXX in the scanner list of the app. Connect to this device and then click on the Client tab. Then, choose "Secure DFU Service".
By default, the BLE signal of the RAK4630 turns off automatically if no connection is established after 60 seconds. Connect to RAK.XXXXXX immediately after pressing the reset button.
 Figure 1: Secure DFU service
Figure 1: Secure DFU service- Click the button highlighted in red, as shown in Figure 13.
 Figure 1: Buttonless DFU
Figure 1: Buttonless DFU- A Write Value window will pop up. Select Bool tab, move the switch from FalsetoTruethen press the Write button.
 Figure 1: Resetting the bootloader via Bluetooth
Figure 1: Resetting the bootloader via Bluetooth- Now, the RAK4630 is in DFU mode. In the application, you will see the default status overview of the RAK4630.
 Figure 1: RAK4630 default status overview after resetting
Figure 1: RAK4630 default status overview after resetting- In the Scanner list, find a BLE device named DfuTarg and then click the Connect button.
 Figure 1: RAK4630 Default Bluetooth ID after Resetting
Figure 1: RAK4630 Default Bluetooth ID after Resetting- After connecting, select the DFU tab, then click Open Document Picker. This will prompt you to select the distribution packet zip file of the firmware you have downloaded. Press OK, and it will automatically start to upgrade the firmware of your RAK4630 through DFU over BLE.
 Figure 1: Distribution Packet File Type under DFU
Figure 1: Distribution Packet File Type under DFUYou can upload the distribution packet (ZIP) file to iCloud Services and download it to your smartphone.
- After upgrading, the module restarts, and the DFU connection disconnects. Now you can use your RAK4630 with the latest firmware.
 Figure 1: DFU upgrading of RAK4630 firmware via BLE
Figure 1: DFU upgrading of RAK4630 firmware via BLEDFU OTA Using Android
OTA DFU Over BLE
- Download the DFU package of the RAK4630 and save it on your mobile phone.
You can upload the Distribution packet (ZIP) file to Google Drive and download it to your smartphone.
Make sure Bluetooth on your mobile device is turned on.
- 
Press the reset button and wait a couple of seconds. 
- 
Open the nRF Connect mobile application. The scanner list will show all BLE devices in range. 
 Figure 1: Available Bluetooth Devices in the Nordic App
Figure 1: Available Bluetooth Devices in the Nordic App- Look for a BLE Device named RAK.XXXXXX in the scanner list of the app. Connect to this device and then click the Client tab. Then, choose Secure DFU Services.
By default, the BLE signal of the RAK4630 turns off automatically if no connection is established after 60 seconds. Connect to RAK.XXXXXX immediately after pressing the reset button.
 Figure 1: Secure DFU service in the Nordic App
Figure 1: Secure DFU service in the Nordic App- Click the button highlighted in red, as shown in Figure 21.
 Figure 1: Buttonless DFU
Figure 1: Buttonless DFU- 
Click the arrow-up button highlighted in a red box. 
- 
A Write value window will pop up. Press the SEND button. 
 Figure 1: Resetting the Bootloader via Bluetooth
Figure 1: Resetting the Bootloader via Bluetooth- Now, the RAK4630 is in DFU mode. The application will show the default status overview of the RAK4630.
 Figure 1: RAK4630 default status overview after resetting
Figure 1: RAK4630 default status overview after resetting- In the Devices list, find a BLE device named DfuTarg and click on the Connect button.
 Figure 1: RAK4630 default Bluetooth ID after resetting
Figure 1: RAK4630 default Bluetooth ID after resettingAfter connecting, click the DFU icon (highlighted in red in Figure 25).
- Select the distribution packet (.ZIP) and press OK. This will prompt you to select the downloaded firmware's ZIP file. The RAK4630's firmware will then automatically upgrade via DFU over BLE.
 Figure 1: Distribution packet file type under DFU
Figure 1: Distribution packet file type under DFUYou can upload the distribution packet (ZIP) file to Google Drive and download it to your smartphone.
- After upgrading, the module restarts, and the DFU connection will be disconnected. You can now use your RAK4630 with the latest firmware.
 Figure 1: DFU upgrading of RAK4630 firmware via BLE
Figure 1: DFU upgrading of RAK4630 firmware via BLE