After uploading with PlatformIO communication via port is not possible. It works fine after uploading from Arduino

Hi

I created a topic here, some time ago, and it was closed automatically, but the issue was not solved.
The issue is that after uploading with PlatformIO communication via the port is not possible. The port is just not listed when I use upload or monitor buttons in PlatformIO. I need to double click the reset button on the board, it switches mode and then I’m able to upload a new application.

It works fine after uploading from Arduino, port is listed and works.

I followed this tutorial and tried running the code mentioned there. Communication with LoRa works fine, but it looks like the serial connection was never initialized.

@beegee - thank you for the support in my previous topic. The speed in platformio.ini is set correctly:

[env:wiscore_rak4631]
platform = nordicnrf52
board = wiscore_rak4631
framework = arduino
lib_deps = beegee-tokyo/SX126x-Arduino@^2.0.8
Monitor_speed = 9600

By modifying my setup() I was able to determine, that serial does never start:

void setup()
{
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, LOW);

  Serial.begin(9600);
  time_t timeout = millis();
  while (!Serial)
  {
    if ((millis() - timeout) < 5000)
    {
      delay(100);
    }
    else
    {
      while (true)
      {
        // turn the LED on (HIGH is the voltage level)
        digitalWrite(LED_BUILTIN, HIGH);
        // wait for a second
        delay(100);
        // turn the LED off by making the voltage LOW
        digitalWrite(LED_BUILTIN, LOW);
        // wait for a second
        delay(100);
        //Serial.println("Type: ABP");
        delay(200);
      }
    }
  }

I see the diode blinking, so 5s. have passed and serial did not start. Why could it be?

Hello @p4vv37 welcome back.

Sounds very much like an old bootloader version.

Can you follow this guide to check your bootloader version.
Anything older than December 2021 should be updated.

Hi,
thanks, that was correct, bootloader version was from 2020.
But after updating it:

UF2 Bootloader 0.4.2 lib/nrfx (v2.0.0) lib/tinyusb (0.10.1-293-gaf8e5a90) lib/uf2 (remotes/origin/configupdate-9-gadbb8c7)
Model: WisBlock RAK4631 Board
Board-ID: WisBlock-RAK4631-Board
Date: Dec  1 2021
SoftDevice: S140 6.1.1

The issue still persists. I changed my code, so if Serial is not initialized a blue led is set to high, and it is, also, the port is not listed still:

void setup()
{
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, LOW);
  // Initialize LoRa chip.
  // lora_rak4630_init();
  // initBme680();

  // Initialize Serial for debug output
  time_t timeout = millis();
  Serial.begin(9600);
  while (!Serial)
  {
    if ((millis() - timeout) < 5000)
    {
      delay(100);
    }
    else
    {
      // turn the LED off by making the voltage LOW
      digitalWrite(LED_BUILTIN2, HIGH);
      break;
    }
  }
  Serial.println("=====================================");
  Serial.println("Welcome to RAK4630 LoRaWan!!!");
  return;

Hello @p4vv37
I have no Linux or MacOS to test, only Windows 10 and the LoRaWAN-OTAA-ABP example compiles without problems on my PlatformIO and I get the serial output:

> Executing task: C:\Users\RAKwireless\.platformio\penv\Scripts\platformio.exe run --target upload --target monitor --environment wiscore_rak4631 <

Processing wiscore_rak4631 (platform: nordicnrf52; board: wiscore_rak4631; framework: arduino)
--------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/nordicnrf52/wiscore_rak4631.html
PLATFORM: Nordic nRF52 (9.0.0) > WisCore RAK4631 Board
HARDWARE: NRF52840 64MHz, 243KB RAM, 796KB Flash      
DEBUG: Current (jlink) External (jlink, stlink)       
PACKAGES:
 - framework-arduinoadafruitnrf52 1.10100.0 (1.1.0)   
 - framework-cmsis 2.50700.210515 (5.7.0)
 - tool-adafruit-nrfutil 1.503.0 (5.3)
 - tool-bossac-nordicnrf52 1.10901.201022 (1.9.1)     
 - tool-openocd 2.1100.211028 (11.0)
 - tool-sreccat 1.164.0 (1.64)
 - toolchain-gccarmnoneeabi 1.70201.0 (7.2.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 14 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <SX126x-Arduino> 2.0.8
|   |-- <SPI> 1.0
|   |   |-- <Adafruit TinyUSB Library>
|-- <SPI> 1.0
|   |-- <Adafruit TinyUSB Library>
Building in release mode
Checking size .pio\build\wiscore_rak4631\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   6.0% (used 14828 bytes from 248832 bytes)
Flash: [==        ]  15.9% (used 129768 bytes from 815104 bytes)
Configuring upload protocol...
AVAILABLE: jlink, nrfjprog, nrfutil, stlink
CURRENT: upload_protocol = nrfutil
Looking for upload port...
Auto-detected: COM14
Forcing reset using 1200bps open/close on port COM14
Waiting for the new upload port...
Uploading .pio\build\wiscore_rak4631\firmware.zip
Upgrading target on COM35 with DFU package C:\Work\Projects\RAK4631-Code\LoRaWAN-OTAA-ABP\.pio\build\wiscore_rak4631\firmware.zip. Flow control is disabled, Single bank, Touch disabled
########################################
########################################
########################################
########################################
########################################
########################################
##############
Activating new firmware
Device programmed.
==================================================== [SUCCESS] Took 12.58 seconds ========================================================--- Available filters and text transformations: colorize, debug, default, direct, hexlify, log2file, nocontrol, printable, sen_entd_on_enter, time
--- More details at https://bit.ly/pio-monitor-filters
--- Miniterm on COM14  9600,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
=====================================
Welcome to RAK4630 LoRaWan!!!
Type: OTAA
Region: AS923-3
=====================================
OTAA Mode, Network Joined!
Sending frame now...
lmh_send ok count 1
Sending frame now...
lmh_send ok count 2 
Sending frame now...
lmh_send ok count 3 
Sending frame now...
lmh_send ok count 4 

Do you try with the MiniTerm of PIO or do you use another terminal program?

It works the same for Arduino and pio monitor of Platform IO. I do not think, that the serial monitor is the problem, apparently, the application uploaded to the board just cannot start a Serial connection.

And just right now I uploaded the same script with Arduino and it works fine, there’s some problem with PlatformIO or configuration I guess…
Arduino IDE looks really limited and hard to use, I’d definitely prefer to use Visual Studio Code and Platform IO

Ok, I was able to compose a makefile that mimics the pipeline of Arduino. It works fine now.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.