0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

📚 VSCode(RL78G14)開発環境の構築 LM1_1_Code

Last updated at Posted at 2025-06-18

QQQ :bow_tone1:3Q!

🧑‍🏫 組み込み開発_RL78G14篇 LC1 :arrow_heading_up:

VSCode試し理由

  • Cursorはe2Studio IDEより軽い
  • AIプラグインよりコーディング効率化

ソースコードの自動生成およびシミュレーターの設計は、e² Studio IDEに任せます。

環境準備

  • e2 Studio + LLVM for RL78 环境

    • 编译 & デバッグ环境
      C:\ProgramData\LLVM for Renesas RL78 17.0.1.202406\bin
    • GNU make環境
      C:\Renesas\e2_studio\eclipse\plugins\com.renesas.ide.exttools.gnumake.win32.x86_64_4.3.0.v20220121-1024\mk
  • VSCode + Renesasプラグイン
    image.png

  • CMakeダウンロード
    Portable、インストール不要
    https://cmake.org/download/
    Binary distributions:
    | Windows x64 ZIP | cmake-4.0.2-windows-x86_64.zip |

  • Ninja ダウンロード
    Portable、インストール不要
    https://github.com/ninja-build/ninja/releases
    ninja-win.zip 269 KBMay 11, 2024

  • CMake & Ninjaの置き場
     C:\cmake\bin
    image.png

  • システムパスへ追加
    image.png

CS+ IDEでの CC_RL または CA_CX コンパイラ環境は使用できません!

e² studioプロジェクトを構築

省略、下記リンクをご参照ください。
LED点消灯を10分で制御させる :arrow_right:

VSCodeプロジェクトの変換/作成

  • 「Ctrl+Shift+P」より「Create LLVM for RL78 project files」メニューを選択
    image.png
  • 二つファイル(CMakeLists.txtとcross.cmake)を生成
    image.png

不要な .c や .s ファイルを削除

(旧プロジェクトのエントリポイントである main 関数付きの廃棄ファイルも含む)
image.png

CMakeLists.txt を編集

Makefile群を生成するため

  • プロジェクト名を記入(例:QQQ)
    image.png
  • 起動アセンブラファイル(start.S)箇所変更伴い、パス変更対応(📁名変更:generate -> src)
    image.png

クロスコンパイル設定

cross.cmakeを編集
image.png

Debug環境を構築

launch.json の生成と編集

  • ✅simulator(シミュレーター環境でのデバッグ)
  • hardware (Lite版ハードウェア回路でのデバッグ)
    image.png

{651D708B-793C-4B62-812B-F204582A2274}.png
image.png
image.png

{
	// IntelliSense を使用して利用可能な属性を学べます。
	// 既存の属性の説明をホバーして表示します。
	// 詳細情報は次を確認してください: https://go.microsoft.com/fwlink/?linkid=830387
	//e2-server-gdb -g 
	//SIMULATOR -usecurityIdSize 10 
	//-t R5F104PL -uConnectionTimeout= 30 
	//-umFreq= 2.00 -usFreq= 32.768 
	//-uresetOnReload= 1 
	//-udisplaySimGUI= 1 
	// -uSimulatorSetting= C:\git\vscode\LLVM\QQQ/QQQ Simulator Debug.simpj 
	// -uRelayBreak= 0 -l 
	// -uCore= SINGLE_CORE|enabled|1|main 
	// -uSyncMode= async 
	// -uFirstGDB= main 
	// --gdbVersion= 12.1
	"version": "0.2.0",
	"configurations": [
		// Renesas GDB Simulator configuration
		// This configuration is used for debugging with the Renesas GDB simulator.
		{
			"type": "renesas-simulator",
			"request": "launch",
			"name": "Renesas GDB Simulator Debugging",
			"target": {
				"deviceFamily": "RL78",
				"device": "R5F104PL",
				"debuggerType": "SIMULATOR",
				"serverParameters": [
					"-usecurityIdSize",
					"10",
					"-t",
					"R5F104PL",
					"-uConnectionTimeout",
					"30",
					"-umFreq",
					"2.00",
					"-usFreq",
					"32.768",
					"-uresetOnReload",
					"1",
					"-udisplaySimGUI",
					"1",
					"-uSimulatorSetting",
					"${workspaceFolder}/QQQ Debug.simpj",
					"-uRelayBreak",
					"0",
					"-l",
					"-uCore",
					"SINGLE_CORE|enabled|1|main",
					"-uSyncMode",
					"async",
					"-uFirstGDB",
					"main"
				],
			}
		},
		// Renesas E2Lite emulator configuration
		// This configuration is used for debugging with the Renesas E2Lite emulator.
		{
			"type": "renesas-hardware",
			"request": "launch",
			"name": "RL78G14 E2Lite emulator",
			"target": {
				"deviceFamily": "RL78",
				"device": "R5F104PL",
				"debuggerType": "E2LITE",
				"serverParameters": [
					"-t",
					"R5F104PL",
					"-uConnectionTimeout=",
					"30",
					"-umFreq=",
					"0",
					"-usFreq=",
					"0",
					"-umClock=",
					"1",
					"-w",
					"0",
					"-usupplyVoltage=",
					"0",
					"-ucommMethod=",
					"0",
					"-usecurityID=",
					"00000000000000000000",
					"-usecurityIdSize",
					"10",
					"-upermitFlash=",
					"1",
					"-uuseWideVoltageMode=",
					"0",
					"-ueraseRom=",
					"1",
					"-uresetOnReload=",
					"1",
					"-ustopTimerEmu=",
					"0",
					"-ustopSerialEmu=",
					"0",
					"-umaskInternalResetSignal=",
					"0",
					"-umaskTargetResetSignal=",
					"0",
					"-n",
					"0",
					"-uverifyOnWritingMemory=",
					"1",
					"-uAllowRRMDMM=",
					"0",
					"-uRelayBreak=",
					"0",
					"-l",
					"-uCore=SINGLE_CORE|enabled|1|main",
					"-uSyncMode=",
					"async",
					"-uFirstGDB=",
					"main",
					"--gdbVersion=",
					"12.1"
				],
				"gdbPath": "C:\\Renesas\\e2studio\\2023-10\\RLSimGDB\\bin\\rl78g14_e2lite_gdb.exe",
			]
		}
	}
]
}

↑↑↑↑↑ 「"${workspaceFolder}/QQQ Debug.simpj",」行にプロジェクト名を更新するべき。例:PROJECT_XXX Debug.simpj
これはe2Studio IDE環境より自動生成したシミュレーター用ファイルです。

CMake操作の実行

(CMake: キャッシュを削除して再構成)
{8EC925C9-1056-4FAB-949D-91165794FE23}.png

[main] プロジェクトを構成しています: QQQ 
[proc] コマンドを実行しています: C:\cmake\bin\cmake.EXE -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE "-DCMAKE_C_COMPILER:FILEPATH=C:\ProgramData\LLVM for Renesas RL78 17.0.1.202406\bin\clang.exe" "-DCMAKE_CXX_COMPILER:FILEPATH=C:\ProgramData\LLVM for Renesas RL78 17.0.1.202406\bin\clang++.exe" -DCMAKE_TOOLCHAIN_FILE=c:/QQQ/QQQ/cross.cmake --no-warn-unused-cli -SC:/QQQ/QQQ -Bc:/QQQ/QQQ/build -G Ninja
[cmake] Not searching for unused variables given on the command line.
[cmake] -- The C compiler identification is Clang 17.0.1
[cmake] -- The CXX compiler identification is Clang 17.0.1
[cmake] -- Detecting C compiler ABI info
[cmake] -- Detecting C compiler ABI info - done
[cmake] -- Check for working C compiler: C:/ProgramData/LLVM for Renesas RL78 17.0.1.202406/bin/clang.exe - skipped
[cmake] -- Detecting C compile features
[cmake] -- Detecting C compile features - done
[cmake] -- Detecting CXX compiler ABI info
[cmake] -- Detecting CXX compiler ABI info - done
[cmake] -- Check for working CXX compiler: C:/ProgramData/LLVM for Renesas RL78 17.0.1.202406/bin/clang.exe - skipped
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - done
[cmake] -- The ASM compiler identification is Clang with GNU-like command-line
[cmake] -- Found assembler: C:/ProgramData/LLVM for Renesas RL78 17.0.1.202406/bin/clang.exe
[cmake] CMake Warning (dev) at CMakeLists.txt:22 (add_custom_command):
[cmake]   Exactly one of PRE_BUILD, PRE_LINK, or POST_BUILD must be given.  Assuming
[cmake]   POST_BUILD to preserve backward compatibility.
[cmake] 
[cmake]   Policy CMP0175 is not set: add_custom_command() rejects invalid arguments.
[cmake]   Run "cmake --help-policy CMP0175" for policy details.  Use the cmake_policy
[cmake]   command to set the policy and suppress this warning.
[cmake] This warning is for project developers.  Use -Wno-dev to suppress it.
[cmake] 
[cmake] -- Configuring done (5.0s)
[cmake] -- Generating done (0.2s)
[cmake] -- Build files have been written to: C:/QQQ/QQQ/build

ビルド開始

コンパイル/リンクを実行し、.elf/.bin ファイルを生成
image.png

デバッグ & 実行

  • 実行ボタン「Renesas GDB Simulator Debugging」を押してデバッグ開始
    {DDA1C964-3022-4C19-B3E3-BF2D760D2569}.png
    image.png

コード生成後は、必ず再度 CMake 操作(キャッシュ削除 → 再構成)を行ってください。

残留課題:
・ 変な浮動演算 ※ 原因不明、しかし、e2Studio環境で算出OK!
  例:uint32_t ulSetParam = (uint32_t) (19999 + 1) * (uint32_t) duty / 100 - 1; →最終ulDuty → 超大きいな値

image.png

:interrobang:なぜ、同じClangコンパイラなのに違いが出るのでしょうか?
image.png

🧑‍🏫 組み込み開発_RL78G14篇 LC1 :arrow_heading_up:
QQQ :bow_tone1:3Q!
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?