Lgt8f328p with Platformio and VSCode - unknown platform

I followed your advise, closed VSCode, deleted “.platformio” directory, and started VSCode again.

But have the same result, trying to compile for LGT8F:

Processing LGT8F328P (platform: lgt8f; board: LGT8F328P; framework: arduino)

Verbose mode can be enabled via -v, --verbose option
UnknownPlatform: Unknown development platform ‘lgt8f’:
File “C:\Users\MiKo.platformio\penv\Lib\site-packages\platformio\builder\main.py”, line 158:
env.LoadPioPlatform()
File “C:\Users\MiKo.platformio\packages\tool-scons\scons-local-4.5.2\SCons\Util\envs.py”, line 242:
return self.method(*nargs, **kwargs)
File “C:\Users\MiKo.platformio\penv\Lib\site-packages\platformio\builder\tools\pioplatform.py”, line 66:
p = env.PioPlatform()
File “C:\Users\MiKo.platformio\packages\tool-scons\scons-local-4.5.2\SCons\Util\envs.py”, line 242:
return self.method(*nargs, **kwargs)
File “C:\Users\MiKo.platformio\penv\Lib\site-packages\platformio\builder\tools\pioplatform.py”, line 40:
return _PioPlatform()
File “C:\Users\MiKo.platformio\penv\Lib\site-packages\platformio\util.py”, line 56:
self.cache[key] = (time.time(), func(*args, **kwargs))
File “C:\Users\MiKo.platformio\penv\Lib\site-packages\platformio\builder\tools\pioplatform.py”, line 36:
return PlatformFactory.from_env(env[“PIOENV”], targets=COMMAND_LINE_TARGETS)
File “C:\Users\MiKo.platformio\penv\Lib\site-packages\platformio\platform\factory.py”, line 100:
p = cls.new(spec, autoinstall=autoinstall)
File “C:\Users\MiKo.platformio\penv\Lib\site-packages\platformio\platform\factory.py”, line 70:
raise UnknownPlatform(pkg_or_spec)
============================================ [FAILED] Took 1.70 seconds ============================================

The there appeared another error message:

pio_error

I think that is not new, but I ignored the message …

I used the same.

Try the exact platformio.ini

[env:LGT8F328P]
platform = lgt8f
board = LGT8F328P
framework = arduino

sorry, same problem …

Please open a CLI and

pio upgrade
pio pkg install -g -p "https://github.com/darkautism/pio-lgt8fx.git"

Then Ctrl+Shift+P → Reload Window and try building again.

Seems to be already up to date

upgrade:

PS D:\Dokumente\PlatformIO\Projects\LoRa-Sensor-On-LGT8F328P> pio upgrade
You're up-to-date!
PlatformIO 6.1.10a4 is currently the newest version available.
PS D:\Dokumente\PlatformIO\Projects\LoRa-Sensor-On-LGT8F328P> 

Install:

PS D:\Dokumente\PlatformIO\Projects\LoRa-Sensor-On-LGT8F328P> pio pkg install -g -p "https://github.com/darkautism/pio-lgt8fx.git"
Platform Manager: Installing git+https://github.com/darkautism/pio-lgt8fx.git
git version 2.29.2.windows.2
Cloning into 'C:\Users\MiKo\.platformio\.cache\tmp\pkg-installing-n3r51jiy'...
remote: Enumerating objects: 37, done.
remote: Counting objects: 100% (37/37), done.
remote: Compressing objects: 100% (24/24), done.
remote: Total 37 (delta 8), reused 29 (delta 6), pack-reused 0R
Receiving objects: 100% (37/37), 10.68 KiB | 781.00 KiB/s, done.
Resolving deltas: 100% (8/8), done.
Platform Manager: lgt8f@1.0.1+sha.7d5d21c has been installed!       
Tool Manager: toolchain-atmelavr@3.70300.220127 is already installed
PS D:\Dokumente\PlatformIO\Projects\LoRa-Sensor-On-LGT8F328P> 

same problem when compiling (didn’t take new screenshot)

I’m absolutely baffled here, I have the exact same PlatformIO core version installed.

PS C:\Users\Max\temp\green> pio system info
--------------------------  --------------------------------------------------------------------
PlatformIO Core             6.1.10a4
Python                      3.11.1-final.0
System Type                 windows_amd64
Platform                    Windows-10
File System Encoding        utf-8
Locale Encoding             cp1252
PlatformIO Core Directory   C:\Users\Max\.platformio
PlatformIO Core Executable  C:\Users\Max\AppData\Roaming\Python\Python311\Scripts\platformio.exe
Python Executable           C:\Program Files\Python311\python.exe
Global Libraries            0
Development Platforms       41
Tools & Toolchains          168
--------------------------  --------------------------------------------------------------------

Can you change the platformio.ini to

[env:LGT8F328P]
platform = https://github.com/darkautism/pio-lgt8fx.git
board = LGT8F328P
framework = arduino

Then repeat these steps

Resolving LGT8F328P dependencies...
Platform Manager: Installing git+https://github.com/darkautism/pio-lgt8fx.git
git version 2.29.2.windows.2
Cloning into 'C:\Users\MiKo\.platformio\.cache\tmp\pkg-installing-b0vygbh0'...

Platform Manager: lgt8f@1.0.1+sha.7d5d21c has been installed!
Tool Manager: Installing toolchain-atmelavr @ >=1.70300.191015
Downloading 0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%
Unpacking 0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%
Tool Manager: toolchain-atmelavr@3.70300.220127 has been installed!
Tool Manager: Installing framework-lgt8fx @ >=1.0.5
Downloading 0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%
Unpacking 0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%
Tool Manager: framework-lgt8fx@1.0.6 has been installed!
Updating metadata for the vscode IDE...
Project has been successfully updated!

The sketch isn’t “empty” now:

Archiving .pio\build\LGT8F328P\libFrameworkArduino.a
Linking .pio\build\LGT8F328P\firmware.elf
Checking size .pio\build\LGT8F328P\firmware.elf
Building .pio\build\LGT8F328P\firmware.hex
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
Error: The program size (30212 bytes) is greater than maximum allowed (29696 bytes)
RAM:   [=======   ]  65.0% (used 1332 bytes from 2048 bytes)
Flash: [==========]  101.7% (used 30212 bytes from 29696 bytes)
*** [checkprogsize] Explicit exit, status 1
=========================================== [FAILED] Took 13.64 seconds ===========================================

I’ll now delete the “few lines” of code and try compiling again …

First off all, many thanks for your great support! :+1:

All problems seems to be fixed and the memory “problem” must be my fault.
Was surprised that this little project (radiohead, bmp280, Si7021) already used up all memory:

Thank you very much!

Okay so now it seems you’re able to compile regular sketches (empty ones at least) again. Can’t tell much about your full sketch, but the list of included libraries and the application code may indeed legimately exceed the flash capacity of the chip. You may be able to check the memory usage using this.

Nice! I’ll check this …

I’ve copied the complete code, that already exceeds the available memory - while several things are not even integrated now, like deep sleep, …

There is another problem - I cant communicte with the LoRa module (RFM95W) on SPI bus.
Permanently getting error -2 (not connected), while the same code works for RFM95W with WEMOS D1 mini Pro.

Is there something special with the SPI bus on LGT8F?

Inspection breaks early at memory check (about 10%):

Welp, not a lot of error message to go on here :frowning:

In any case though, in your previous full sketch, it seems like it does generate the .elf file and then just fails in the post checks (because the full 32K is not available due to a boodloader I assume). Which means you should be able to do the following:

  1. Let GCC generate a map file (Generate a .map file - #8 by Krishna_Chaitanya)
  2. throw that in amap.

Just a side note, “framework-lgt8fx @ 1.0.6” is over 3 years old. They did work on SPI, low power, and more. 2.0.6 is the current release for use with Arduino IDE. . GitHub - dbuezas/lgt8fx: Board Package for Logic Green LGT8F328P LGT8F328D and LGT8F88D
Tried to make a framework but never could get it to work. Might take another run at the docs and try again.
Sorry fir the interruption.

<edit: typos>

Yes, same here.
Trying to update to 2.0.6 will have been the reason for my problems, leading to this topic …

Do you have a link for where to start?

This answer is correct in terms of upgrading: https://github.com/dbuezas/lgt8fx/issues/15#issuecomment-751517482

Basically, download https://github.com/dbuezas/lgt8fx/blob/master/lgt8f-2.0.6.zip, add package.json to the core’s root, point to it using platform_packages and the symlink:// protocol. You can also reupoad that 2.0.6 version with the package.json to Github to enable you to use a Github link instead.

I’ll try this later, because the code is not nearly complete, so will just need more flash or other (own?) libs.
Changed from radiohead lib to the outdated LoraLib reduced the amount of used flash to 64,9% (from 101,8% ).

I’ll try this …

How would a “platformio.ini” look like, with platform_packages and the symlink:// pointing to a local directory?

I would look like the documentation says.

platform_packages = 
   framework-arduino-avr-lgt8f@symlink://C:\Users\SomeUser\Desktop\lgt8f-2.0.6\lgt8f

Thanks a lot!!
Couldn’t find it here: platform_packages
But there: local-folder
Sorry …

Now, with replaced Radiohead Lib, the code compiles without problems:

Compiling .pio\build\LGT8F328P\FrameworkArduino\wiring_shift.c.o
Archiving .pio\build\LGT8F328P\libFrameworkArduino.a
Linking .pio\build\LGT8F328P\firmware.elf
Building .pio\build\LGT8F328P\firmware.hex
Checking size .pio\build\LGT8F328P\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [====      ]  44.3% (used 907 bytes from 2048 bytes)
Flash: [======    ]  64.9% (used 19266 bytes from 29696 bytes)
=========================================== [SUCCESS] Took 6.86 seconds ===========================================
 *  Terminal will be reused by tasks, press any key to close it. 

… but “inspection” fails the same way - break after about 10% memory check and the only result is
“Invalid params” (like previous screenshot).

Changed the “platformio.ini”:

[env:LGT8F328P]
platform = https://github.com/darkautism/pio-lgt8fx.git
platform_packages = 
   framework-arduino-avr-lgt8f@symlink://C:\Users\XYXY\.platformio\packages\lgt8f-2.0.6\lgt8f
board = LGT8F328P
framework = arduino
monitor_speed = 57600
upload_speed = 57600
board_build.f_cpu = 16000000L
board_build.clock_source = 1
lib_deps = 
	;jgromes/RadioLib@^6.0.0
	jgromes/LoRaLib@^8.2.0
	adafruit/Adafruit BMP280 Library@^2.6.8
	adafruit/Adafruit Si7021 Library@^1.5.1
	adafruit/Adafruit Unified Sensor@^1.1.9

[platformio]
description = LoRa Sensor Node

Uses slightly more memory:

Archiving .pio\build\LGT8F328P\libFrameworkArduino.a
Linking .pio\build\LGT8F328P\firmware.elf
Building .pio\build\LGT8F328P\firmware.hex
Checking size .pio\build\LGT8F328P\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [====      ]  44.8% (used 917 bytes from 2048 bytes)
Flash: [=======   ]  67.8% (used 20124 bytes from 29696 bytes)
=========================================== [SUCCESS] Took 6.37 seconds ===========================================
 *  Terminal will be reused by tasks, press any key to close it. 

But, no change to the results of “Inspect”.