Adapt platformio.ini to reproduce Arduino IDE settings

Hi, everyone.

I have a project that I usually burn into a custom nRF52840 board using VS Code.

But there is an issue: when I burn it using VS Code, the chip will only run if it’s attached and powered by a PC USB. When I use a wall adapter or PPK, it doesn’t work (curiously, only the watchdog works).

However, when I burn using Arduino IDE, it works fine using a wall adapter or PPK. Same code, same bootloader and same board.

How can I check all the config of Arduino IDE to reproduce in platformio.ini?

Presently, my platformio.ini is just:

[env:Minew_ME25LS01]
framework = arduino
platform = https://github.com/Seeed-Studio/platform-seeedboards.git
board = nrf-nrf52840-teste
board_build.variant = nrf-nrf52840-teste
board_build.variants_dir = variants
build_flags = -I variants/nrf-nrf52840-teste

What else can I add to it be alike the Arduino IDE settings?

Thank you all for any insight.

Does your oscilloscope lead you to think this isn’t just a power supply problem?

Do a verbose build in the Arduino IDE (File → Preferences → Show verbose output during compile) and in PlatformIO (project tasks → Advanced → Verbose Build), compare both commands for compiler flags, defines and include folders.

If both are equivalent, check that the Arduino core files are the same for both.

Hi, Robert.

The very same board + wall adapter/PPK works fine after being programed in Arduino IDE.

Actually, by the PPK I can see that the power consumption is far away from the power supply max.

From all the probable issues, I truly don’t think power is among them,

I, Max.

I checked the files and they all are the same, as long as I could understand.

That’s the board file I did (basically, it’s a copy of the original one) and it matches with configs in Arduino IDE.

{
  "build": {
    "arduino": {
      "ldscript": "nrf52840_s140_v7.ld"
    },
    "core": "nRF5",
    "cpu": "cortex-m4",
    "extra_flags": "-DARDUINO_Seeed_XIAO_nRF52840 -DNRF52840_XXAA -DSEEED_XIAO_NRF52840 ",
    "f_cpu": "64000000L",
    "hwids": [
      [
        "0x2886",
        "0x8044"
      ],
      [
        "0x2886",
        "0x0044"
      ]
    ],
    "mcu": "nrf52840",
    "variant": "nrf-nrf52840-teste",
    "variants_dir": "variants",
    "softdevice": {
      "sd_flags": "-DS140",
      "sd_name": "s140",
      "sd_version": "7.3.0",
      "sd_fwid": "0x0123"
    },
    "bsp": {
      "name": "adafruit"
    },
    "usb_product": "XIAO nRF52840"
  },
  "connectivity": [
    "bluetooth"
  ],
  "debug": {
    "jlink_device": "nRF52840_xxAA",
    "openocd_target": "nrf52.cfg",
    "svd_path": "nrf52840.svd"
  },
  "frameworks": [
    "arduino"
  ],
  "name": "nrf-nrf52840-teste",
  "upload": {
    "maximum_ram_size": 237568,
    "maximum_size": 811008,
    "protocol": "nrfutil",
    "speed": 115200,
    "protocols": [
      "jlink",
      "nrfjprog",
      "nrfutil",
      "cmsis-dap",
      "sam-ba",
      "blackmagic"
    ],
    "use_1200bps_touch": true,
    "require_upload_port": true,
    "wait_for_upload_port": true
  },
  "url": "http://www.minew.com",
  "vendor": "Minew"
}

Maybe somehow I’m setting some register that needs VUSB, I don’t know what else I could do :frowning:

Do you have full log files for both? Upload to e.g. pastebin.com and link them here.

With command redirection

pio run -v  > pio_log.txt 2>&1

in the PIO CLI you can produce the logs for PIO. With Ctrl+A, Ctrl+C in the Arduino IDE compiler output window, you can produce the logs for Arduino.

I tried to upload to pastebin, but the logs were marked as spam, even after I created a profile.

I uploaded the files with the two outputs in LimeWire.

Again, thank you for your availability :))