Custom board for nRF52840

Hi, everyone.

I did a custom board centered on a nRF52840, using a Minew module ME25LS01. Editing a Seeed XIAO board as example, I managed to edit variant files and put all the GPIO to work :slight_smile:

However Iโ€™d like these changes to be within my projectโ€™s folder, so I could share it and protect from updates etc

The closest I got was a reference from this topic, but Iโ€™m failing to succeed.

My current folder structure is

project_root/
โ”œโ”€โ”€ boards/
โ”‚   โ””โ”€โ”€ Minew_ME25LS01.json
โ”œโ”€โ”€ variants/
โ”‚   โ””โ”€โ”€ Minew_ME25LS01/
โ”‚       โ”œโ”€โ”€ pins_arduino.h
โ”‚       โ”œโ”€โ”€ variant.h
โ”‚       โ””โ”€โ”€ variant.cpp
โ”œโ”€โ”€ lib/
โ””โ”€โ”€ src/

For the JSON file I have copy-paste of the original one

{
  "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": "Minew_ME25LS01",
    "variants_dir": "custom_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": "Seeed Studio XIAO nRF52840",
  "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": "https://wiki.seeedstudio.com/XIAO_BLE",
  "vendor": "Seeed Studio"
}

And for my *.ini

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

And where Iโ€™m stuck at, when attempt to compile is

Resolving Minew_ME25LS01 dependencies...
Already up-to-date.
Updating metadata for the vscode IDE...
UserSideException: Processing Minew_ME25LS01 (framework: arduino; platform: https://github.com/Seeed-Studio/platform-seeedboards.git; board: Minew_ME25LS01)
--------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
no config Architecture
AttributeError: 'NoneType' object has no attribute 'get':
  File "C:\Users\Leandro\.platformio\penv\Lib\site-packages\platformio\builder\main.py", line 158:
    env.LoadPioPlatform()
  File "C:\Users\Leandro\.platformio\packages\tool-scons\scons-local-4.8.1\SCons\Util\envs.py", line 252:
    return self.method(*nargs, **kwargs)
  File "C:\Users\Leandro\.platformio\penv\Lib\site-packages\platformio\builder\tools\pioplatform.py", line 108:
    if isinstance(board_config.get(option), bool):
========================== [FAILED] Took 0.74 seconds ==========================

The verbose-buid adds no more information.

Any help or advise would be great.

Thank you in advance. Many thanks.

So, youโ€™re running into this error message.

Hi, Max,

great insight. I changed the name of the board and I got somewhere else. thank you very much for this.

My custom board has now โ€˜nrfโ€™ in its name (as the original board has)

I changed the structure to

project_root/
โ”œโ”€โ”€ boards/
|   โ”œโ”€โ”€ nrf-teste.json
โ”‚   โ””โ”€โ”€ Minew_ME25LS01.json
โ”œโ”€โ”€ variants/
|   โ”œโ”€โ”€ Minew_ME25LS01/
โ”‚   โ””โ”€โ”€ nrf-teste/
โ”‚       โ”œโ”€โ”€ pins_arduino.h
โ”‚       โ”œโ”€โ”€ variant.h
โ”‚       โ””โ”€โ”€ variant.cpp
โ”œโ”€โ”€ lib/
โ””โ”€โ”€ src/

And now I have another error message

Building in release mode
Compiling .pio\build\Minew_ME25LS01\src\main.cpp.o
Compiling .pio\build\Minew_ME25LS01\lib68a\RadioLib\Hal.cpp.o
Compiling .pio\build\Minew_ME25LS01\lib68a\RadioLib\Module.cpp.o
Compiling .pio\build\Minew_ME25LS01\lib68a\RadioLib\hal\Arduino\ArduinoHal.cpp.o
Compiling .pio\build\Minew_ME25LS01\lib68a\RadioLib\hal\RPiPico\PicoHal.cpp.o
Compiling .pio\build\Minew_ME25LS01\lib68a\RadioLib\modules\CC1101\CC1101.cpp.o
Compiling .pio\build\Minew_ME25LS01\lib68a\RadioLib\modules\LLCC68\LLCC68.cpp.o
Compiling .pio\build\Minew_ME25LS01\lib68a\RadioLib\modules\LR11x0\LR1110.cpp.o
src\main.cpp:1:10: fatal error: Arduino.h: No such file or directory

Apparently, I did change the path to my board, but now it wonโ€™t find Arduino.h.

The platform.ini I kept the same, just changing the original name to the new name everywhere.

Any clue on how to use my custom board variant and still point to the correct path for Arduino.h?

Maybe itโ€™s not triggering the builder script for the right Arduino core? Itโ€™s demanding you have โ€œ52840โ€ in your board definition name.

Honestly, the Seeed platform is one of the worst written platforms Iโ€™ve seen, lots of custom special cases and weird things like having to have certain words in your board name to trigger the right things. Are you sure you canโ€™t do this with the regular platformio/nordicnrf52? Does it need the Seeed version of the Arduino core?

Thanks, Max. Adding โ€˜52840โ€™ into the board name solved the problem. I though that only adding โ€˜nrfโ€™ would be enough.

Indeed Seeed platform isnโ€™t great, quite the oppositeโ€ฆ We started using it because in our custom board, using a Minew Module, it was the only one we managed to make to work. We tried the platforms of Nordic and Adafruit, in this order of preference, but no success (bootloader didnโ€™t work, code didnโ€™t compile etc).

Iโ€™m having a problem to run the board using power-only, it only runs using USB (power+data) cable. I guess something in Seeed config is the problem.

It would be great to use official platformio/nordicnrf52! Any hints, tips or guide youโ€™d suggest? We could try again.

We are using this module.

Any way, thanks again for all your help so far.