QQQ
3Q!
🧑🏫 組み込み開発_RL78G14篇 LC1
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
- 编译 & デバッグ环境
-
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
CS+ IDEでの CC_RL または CA_CX コンパイラ環境は使用できません!
e² studioプロジェクトを構築
省略、下記リンクをご参照ください。
LED点消灯を10分で制御させる
VSCodeプロジェクトの変換/作成
不要な .c や .s ファイルを削除
(旧プロジェクトのエントリポイントである main 関数付きの廃棄ファイルも含む)
CMakeLists.txt を編集
Makefile群を生成するため
クロスコンパイル設定
Debug環境を構築
launch.json の生成と編集
{
// 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操作の実行
[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 ファイルを生成
デバッグ & 実行
コード生成後は、必ず再度 CMake 操作(キャッシュ削除 → 再構成)を行ってください。
残留課題:
・ 変な浮動演算 ※ 原因不明、しかし、e2Studio環境で算出OK!
例:uint32_t ulSetParam = (uint32_t) (19999 + 1) * (uint32_t) duty / 100 - 1; →最終ulDuty → 超大きいな値
なぜ、同じClangコンパイラなのに違いが出るのでしょうか?