How to add LGT8FX board?

I am trying to add the LGT8FX board (fake Arduino Nano with a AVGA328P or LGT8F328P chip) to platformio, but I am having a hard time. I downloaded a board package from GitHub - dbuezas/lgt8fx: Board Package for Logic Green LGT8F328P LGT8F328D and LGT8F88D, which gives me the following file structure:

lgt8f\
    bootloaders\
    cores\
    libraries\
    variants\
    boards.txt
    platform.txt
    programmers.txt

How can I add this to platformio? Reading Custom Platform & Board — PlatformIO latest documentation did not really made it clearer from me. I understand that I need to make a myboard.json, which I did, contents of my wavgatnano.json (made by looking at boards.txt and so on):

{
  "build": {
    "core": "lgt8f",
    "extra_flags": "-DARDUINO_AVR_NANO",
    "f_cpu": "16000000L",
    "mcu": "avga328p",
    "variant": "lgt8fx8p"
  },
  "bootloader": {
    "efuse": "0xFD",
    "file": "lgt8fx8p/optiboot_lgt8f328p.hex",
    "hfuse": "0xFF",
    "lock_bits": "0x3F",
    "lfuse": "0xFF",
    "unlock_bits": "0x3F"
  },
  "frameworks": [
    "arduino"
  ],
  "name": "WAVGAT Nano AVGA328P",
  "upload": {
    "maximum_ram_size": 2048,
    "maximum_size": 29696,
    "protocol": "arduino",
    "require_upload_port": true,
    "speed": 57600
  },
  "url": "https://someurl.com/",
  "vendor": "wavgat"
}

But simply putting this json in Project/boards ofcourse does not work. Where do I need to copy paste the entire package, and what other changes do I need to make?

This topic added the original chinese Larudino package to PlatformIO: How can i add a boards that can work with arduinoide

For the lgt8fx core you pretty much do the same: Create your own framework-arduino-avr-lgt8fx packges which is correctly formatted (package.json, see mine), define your board files with the right core, variant and bascically all other settings that your target core defines in its boards.txt (you seem to have already done that). Then select the board via board = wavgatnano in the platformio.ini and see if it compiles.

2 Likes

Thank you for your help. I managed to add the board package manually, and wrote all steps for myself in a git repo: GitHub - rick3rt/framework-arduino-avr-lgt8f: framework-arduino-avr-lgt8f for WAVGAT board development in PlatformIO .

From the topic you linked I understand that you can automate the installation with the framework-package configuration in the ini. However, if I create the following ini, this does not work:

[env:wavgatnano]
platform = atmelavr
board = wavgatnano
framework = arduino
framework-package = framework-arduino-avr-lgt8f @ https://github.com/rick3rt/framework-arduino-avr-lgt8f.git
upload_protocol = arduino

If I build a simple blink example, I get the folliwing error:

> Executing task: C:\Users\myusername\.platformio\penv\Scripts\platformio.exe run <

Processing nanowavgat (platform: atmelavr; board: wavgatnano; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Error: Traceback (most recent call last):
  File "c:\users\myusername\.platformio\penv\lib\site-packages\platformio\__main__.py", line 102, in main
    cli()  # pylint: disable=no-value-for-parameter
  File "c:\users\myusername\.platformio\penv\lib\site-packages\click\core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "c:\users\myusername\.platformio\penv\lib\site-packages\click\core.py", line 717, in main
    rv = self.invoke(ctx)
  File "c:\users\myusername\.platformio\penv\lib\site-packages\platformio\commands\__init__.py", line 44, in invoke
    return super(PlatformioCLI, self).invoke(ctx)
  File "c:\users\myusername\.platformio\penv\lib\site-packages\click\core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\users\myusername\.platformio\penv\lib\site-packages\click\core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\users\myusername\.platformio\penv\lib\site-packages\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "c:\users\myusername\.platformio\penv\lib\site-packages\click\decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "c:\users\myusername\.platformio\penv\lib\site-packages\platformio\commands\run\command.py", line 128, in cli
    process_env(
  File "c:\users\myusername\.platformio\penv\lib\site-packages\platformio\commands\run\command.py", line 170, in process_env
    result = {"env": name, "duration": time(), "succeeded": ep.process()}
  File "c:\users\myusername\.platformio\penv\lib\site-packages\platformio\commands\run\processor.py", line 81, in process
    result = p.run(build_vars, build_targets, self.silent, self.verbose, self.jobs)
  File "c:\users\myusername\.platformio\penv\lib\site-packages\platformio\managers\platform.py", line 398, in run
    self.configure_default_packages(options, targets)
  File "C:\Users\myusername\.platformio\platforms\atmelavr\platform.py", line 39, in configure_default_packages
    self.packages[framework_package]["optional"] = False
KeyError: 'framework-arduino-avr-lgt8f'

============================================================

An unexpected error occurred. Further steps:

* Verify that you have the latest version of PlatformIO using
  `pip install -U platformio` command

* Try to find answer in FAQ Troubleshooting section
  https://docs.platformio.org/page/faq.html

* Report this problem to the developers
  https://github.com/platformio/platformio-core/issues

============================================================

The terminal process terminated with exit code: 1

Terminal will be reused by tasks, press any key to close it.

But if I manually add the package name to .platformio\platforms\atmelavr\platform.json it will auto clone from git and work.

"packages": {
    "framework-arduino-avr": {
      "type": "framework",
      "optional": true,
      "version": "~5.0.0"
    },
    "framework-arduino-avr-lgt8f": {
      "type": "framework",
      "optional": true,
      "version": "1.0.0"
    }
}

Is this intentional?

Incorrect syntax in a platformio.ini. Refer to my example

and docs

1 Like

Ah right, thx got it to work now. One thing though. I thought that I only had to use the ’ @ gitrepo ’ for the first time to let it clone the repo.

But if I now omit the gitrepo, i.e.

[env:wavgatnano]
platform = atmelavr
board = wavgatnano
framework = arduino
platform-package = framework-arduino-avr-lgt8f
upload_protocol = arduino

it will complain that it cannot detected an unknown package:

> Executing task: C:\Users\rinkert\.platformio\penv\Scripts\platformio.exe run <

Processing wavgat (platform: atmelavr; board: wavgatnano; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
PackageManager: Installing framework-arduino-avr-lgt8f @ *
Error: Detected unknown package 'framework-arduino-avr-lgt8f'
The terminal process terminated with exit code: 1

Terminal will be reused by tasks, press any key to close it.

Is this intended behavior? The folder framework-arduino-avr-lgt8f is already available in ~\.platformio\packages.

Must be named platform_packages and without a source it’s also invalid.

I think what’s happening internally here is that it’s not finding it because it’s not listed within the platform’s available packages (platform-atmelavr/platform.json at develop · platformio/platform-atmelavr · GitHub). The platform_packages = .. directive nicely works around it by dynamically adding it, I think. If you wanted to properly integrate it, you’d just add the framework-arduino-avr-lgt8f package into theplatform.json of a modified platform-atmelavr fork and point the platform = atmelavr @ <gitrepolink..>.

1 Like

Ok thx for the explanation. I guess I will just keep adding the git repo. That’s the easiest solution for me, and I am not planning on using this board too often. Thx for your help!

1 Like

I actually saw in your repo that you do modify the platform.json. But then it also has to be available in one of the manifests of the package repositories, see

So for that you’d have to open your own package repository github with a manifest.json which then describes where the package can be downloaded, as in the docs. That should be the missing puzzle piece.

1 Like

Thanks, with that last pointer I made it such that I don’t have to manually configure anything in the .platformio directory. So my platformio.ini becomes

[env:wavgat]
platform = https://github.com/rick3rt/platform-atmelavr.git
board = wavgatnano
framework = arduino
platform_packages = framework-arduino-avr-lgt8f@https://github.com/rick3rt/framework-arduino-avr-lgt8f.git
1 Like