Skip to content

Commit 4512586

Browse files
committed
iar arm compiler supported
1 parent 74d067a commit 4512586

12 files changed

Lines changed: 756 additions & 52 deletions

lang/arm.iar.verify.json

Lines changed: 467 additions & 0 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,12 @@
378378
"markdownDescription": "%settings.iar.stm8.install.folder%",
379379
"default": ""
380380
},
381+
"EIDE.IAR.ARM.Toolchain.InstallDirectory": {
382+
"type": "string",
383+
"scope": "machine",
384+
"markdownDescription": "%settings.iar.arm.toolchain.install.folder%",
385+
"default": ""
386+
},
381387
"EIDE.STM8.GNU-SDCC.InstallDirectory": {
382388
"type": "string",
383389
"scope": "machine",
@@ -1496,6 +1502,10 @@
14961502
"fileMatch": "**/*.options.gcc.json",
14971503
"url": "./lang/arm.gcc.verify.json"
14981504
},
1505+
{
1506+
"fileMatch": "**/*.options.arm.iar.json",
1507+
"url": "./lang/arm.iar.verify.json"
1508+
},
14991509
{
15001510
"fileMatch": "**/*.stm8.gnu-sdcc.json",
15011511
"url": "./lang/stm8.gnu-sdcc.verify.json"

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117

118118
"settings.keilc51.ini": "Keil C51 `UV4.exe` or `TOOLS.INI` file path [`example: C:\\Keil_v5\\UV4\\UV4.exe`]",
119119
"settings.iar.stm8.install.folder": "IAR for STM8 install directory [`example: D:\\IAR`]",
120+
"settings.iar.arm.toolchain.install.folder": "IAR ARM C/C++ Compiler root directory [`example: D:\\IAR_ARM\\arm`]",
120121
"settings.sdcc.install.folder": "SDCC install folder [`example: C:\\Program Files (x86)\\SDCC`]",
121122

122123
"settings.arm.armcc5.install.folder": "Armcc v5 toolchain install directory [`example: D:\\ac5`]",

package.nls.zh-CN.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107

108108
"settings.keilc51.ini": "Keil C51 `UV4.exe` 或 `TOOLS.INI` 文件路径 [`example: C:\\Keil_v5\\UV4\\UV4.exe`]",
109109
"settings.iar.stm8.install.folder": "IAR for STM8 安装目录 [`example: D:\\IAR`]",
110+
"settings.iar.arm.toolchain.install.folder": "IAR ARM C/C++ 编译器根目录 [`example: D:\\IAR_ARM\\arm`]",
110111
"settings.sdcc.install.folder": "SDCC 安装目录 [`example: C:\\Program Files (x86)\\SDCC`]",
111112

112113
"settings.arm.armcc5.install.folder": "Armcc v5 toolchain 安装目录 [`example: D:\\ac5`]",

src/CodeBuilder.ts

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -893,29 +893,46 @@ export class ARMCodeBuilder extends CodeBuilder {
893893
scatterFilePath = `${scatterFilePath}.sct`;
894894
}
895895

896-
// 'armcc' can select whether use custom linker file
897-
if (['AC5', 'AC6'].includes(toolchain.name)) {
898-
// use custom linker script files
899-
if (config.compileConfig.useCustomScatterFile) {
900-
scatterFilePath.split(',')
901-
.filter(s => s.trim() != '')
902-
.forEach((sctPath) => {
903-
ldFileList.push(`"${File.ToUnixPath(this.project.ToAbsolutePath(sctPath))}"`);
904-
});
905-
}
906-
// auto generate scatter file
907-
else {
908-
ldFileList.push(`"${File.ToUnixPath(this.GenMemScatterFile(config).path)}"`);
909-
}
910-
}
896+
switch (toolchain.name) {
897+
// 'armcc' can select whether use custom linker file
898+
case 'AC5':
899+
case 'AC6':
900+
{
901+
if (config.compileConfig.useCustomScatterFile) { // use custom linker script files
902+
scatterFilePath.split(',')
903+
.filter(s => s.trim() != '')
904+
.forEach((sctPath) => {
905+
ldFileList.push(`"${File.ToUnixPath(this.project.ToAbsolutePath(sctPath))}"`);
906+
});
907+
} else { // auto generate scatter file
908+
ldFileList.push(`"${File.ToUnixPath(this.GenMemScatterFile(config).path)}"`);
909+
}
910+
}
911+
break;
911912

912-
// other toolchain must use custom linker script file
913-
else {
914-
scatterFilePath.split(',')
915-
.filter(s => s.trim() != '')
916-
.forEach((sctPath) => {
917-
ldFileList.push(`"${File.ToUnixPath(this.project.ToAbsolutePath(sctPath))}"`);
918-
});
913+
// arm gcc
914+
case 'GCC':
915+
{
916+
scatterFilePath.split(',')
917+
.filter(s => s.trim() != '')
918+
.forEach((sctPath) => {
919+
ldFileList.push(`"${File.ToUnixPath(this.project.ToAbsolutePath(sctPath))}"`);
920+
});
921+
}
922+
break;
923+
924+
// iar
925+
case 'IAR_ARM':
926+
{
927+
scatterFilePath.split(',')
928+
.filter(s => s.trim() != '')
929+
.forEach((sctPath) => {
930+
ldFileList.push(`"${File.ToUnixPath(this.project.ToAbsolutePath(sctPath))}"`);
931+
});
932+
}
933+
break;
934+
default:
935+
break;
919936
}
920937

921938
// set linker script

src/EIDEProject.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ export abstract class AbstractProject implements CustomConfigurationProvider, Pr
723723
static readonly excludeDirFilter: RegExp = /^\./;
724724

725725
// to show output files
726-
static readonly buildOutputMatcher: RegExp = /\.(?:elf|axf|out|hex|ihx|bin|s19|sct|ld[s]?|map|map\.view)$/i;
726+
static readonly buildOutputMatcher: RegExp = /\.(?:elf|axf|out|a|lib|hex|ihx|bin|s19|s37|sct|icf|ld[s]?|map|map\.view)$/i;
727727

728728
//-------
729729

@@ -2167,11 +2167,11 @@ class EIDEProject extends AbstractProject {
21672167

21682168
try {
21692169
const refMap = JSON.parse(refListFile.Read());
2170-
for (const srcName in refMap) {
2171-
const refFile = new File((<string>refMap[srcName]).replace(/\.[^\\\/\.]+$/, '.d'));
2170+
for (const srcpath in refMap) {
2171+
const refFile = new File((<string>refMap[srcpath]).replace(/\.[^\\\/\.]+$/, '.d'));
21722172
if (!refFile.IsFile()) continue;
2173-
const refs = this.parseRefFile(refFile, toolName);
2174-
this.srcRefMap.set(srcName, refs.map((path) => new File(path)));
2173+
const refs = this.parseRefFile(refFile, toolName).filter(p => p != srcpath);
2174+
this.srcRefMap.set(srcpath, refs.map((path) => new File(path)));
21752175
}
21762176
} catch (error) {
21772177
GlobalEvent.emit('msg', ExceptionToMessage(error, 'Hidden'));
@@ -2248,8 +2248,9 @@ class EIDEProject extends AbstractProject {
22482248
switch (toolchain) {
22492249
case "AC5":
22502250
return this.ac5_parseRefLines(lines);
2251+
case "IAR_ARM":
22512252
case "IAR_STM8":
2252-
return this.ac5_parseRefLines(lines, 2);
2253+
return this.ac5_parseRefLines(lines, 1);
22532254
case "SDCC":
22542255
case "AC6":
22552256
case "GCC":

src/EIDEProjectModules.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,8 @@ export abstract class CompileConfigModel<T> extends ConfigModel<T> {
416416
return <any>new Keil51CompileConfigModel(prjConfigData);
417417
case 'IAR_STM8':
418418
return <any>new Iarstm8CompileConfigModel(prjConfigData);
419+
case 'IAR_ARM':
420+
return <any>new IarArmCompileConfigModel(prjConfigData);
419421
case 'AC5':
420422
return <any>new Armcc5CompileConfigModel(prjConfigData);
421423
case 'AC6':
@@ -994,6 +996,61 @@ export class GccCompileConfigModel extends ArmBaseCompileConfigModel {
994996
}
995997
}
996998

999+
export class IarArmCompileConfigModel extends ArmBaseCompileConfigModel {
1000+
1001+
protected cpuTypeList = [
1002+
'ARM7EJ-S',
1003+
'ARM7TDMI',
1004+
'ARM720T',
1005+
'ARM7TDMI-S',
1006+
'ARM9TDMI',
1007+
'ARM920T',
1008+
'ARM922T',
1009+
'ARM9E-S',
1010+
'ARM926EJ-S',
1011+
'ARM946E-S',
1012+
'ARM966E-S',
1013+
'Cortex-M0',
1014+
'Cortex-M0+',
1015+
'Cortex-M3',
1016+
'Cortex-M4',
1017+
'Cortex-M7',
1018+
//'Cortex-R4',
1019+
//'Cortex-R4F',
1020+
'SC000',
1021+
'SC300'
1022+
];
1023+
1024+
protected GetKeyType(key: string): FieldType {
1025+
switch (key) {
1026+
case 'cpuType':
1027+
case 'floatingPointHardware':
1028+
return 'SELECTION';
1029+
case 'scatterFilePath':
1030+
return 'INPUT';
1031+
case 'options':
1032+
return 'EVENT';
1033+
default:
1034+
return 'Disable';
1035+
}
1036+
}
1037+
1038+
static getDefaultConfig(): ArmBaseCompileData {
1039+
return {
1040+
cpuType: 'Cortex-M3',
1041+
floatingPointHardware: 'none',
1042+
scatterFilePath: '${ToolchainRoot}/config/linker/ST/stm32f103x8.icf',
1043+
useCustomScatterFile: false,
1044+
storageLayout: { RAM: [], ROM: [] },
1045+
options: 'null'
1046+
};
1047+
}
1048+
1049+
GetDefault(): ArmBaseCompileData {
1050+
return IarArmCompileConfigModel.getDefaultConfig();
1051+
}
1052+
}
1053+
9971054
// -------- RISC-V --------
9981055

9991056
// deprecated

src/HexUploader.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ export interface HexUploaderInfo {
6363
export class HexUploaderManager {
6464

6565
private uploaderList: HexUploaderInfo[] = [
66-
{ type: 'JLink', description: 'for Cortex-M chips, only JLink interface', filters: ['AC5', 'AC6', 'GCC', 'RISCV_GCC', 'ANY_GCC'] },
67-
{ type: 'STLink', description: 'for STM32 chips, only STLink interface', filters: ['AC5', 'AC6', 'GCC'] },
68-
{ type: 'pyOCD', description: 'for Cortex-M chips', filters: ['AC5', 'AC6', 'GCC', 'RISCV_GCC', 'ANY_GCC'] },
69-
{ type: 'OpenOCD', description: 'for Cortex-M chips', filters: ['AC5', 'AC6', 'GCC', 'RISCV_GCC', 'ANY_GCC'] },
66+
{ type: 'JLink', description: 'for Cortex-M chips, only JLink interface', filters: ['AC5', 'AC6', 'GCC', 'IAR_ARM', 'RISCV_GCC', 'ANY_GCC'] },
67+
{ type: 'STLink', description: 'for STM32 chips, only STLink interface', filters: ['AC5', 'AC6', 'GCC', 'IAR_ARM'] },
68+
{ type: 'pyOCD', description: 'for Cortex-M chips', filters: ['AC5', 'AC6', 'GCC', 'IAR_ARM', 'RISCV_GCC', 'ANY_GCC'] },
69+
{ type: 'OpenOCD', description: 'for Cortex-M chips', filters: ['AC5', 'AC6', 'GCC', 'IAR_ARM', 'RISCV_GCC', 'ANY_GCC'] },
7070
{ type: 'stcgal', description: 'for STC chips', filters: ['Keil_C51', 'SDCC'] },
7171
{ type: 'STVP', description: 'for STM8 chips, only STLink interface', filters: ['IAR_STM8', 'SDCC'] },
7272
{ type: 'Custom', label: 'Shell', description: 'download program by custom shell command' }

src/OperationExplorer.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,11 @@ export class OperationExplorer {
239239

240240
//---
241241

242-
const tcList: ToolchainName[] = ['AC5', 'GCC', 'IAR_STM8', 'SDCC', 'Keil_C51', 'RISCV_GCC', 'ANY_GCC', 'GNU_SDCC_STM8'];
242+
const tcList: ToolchainName[] = ['AC5', 'AC6', 'GCC', 'IAR_ARM', 'IAR_STM8', 'SDCC', 'Keil_C51', 'RISCV_GCC', 'ANY_GCC'];
243243
const toolchainManager = ToolchainManager.getInstance();
244-
const checkResults = tcList.map((tcName) => { return toolchainManager.isToolchainPathReady(tcName); });
245-
const status: CheckStatus = checkResults.every((val) => { return val; }) ?
246-
CheckStatus.All_Verified : (checkResults.includes(true) ? CheckStatus.All_Verified : CheckStatus.All_Failed);
244+
const status: CheckStatus = tcList.some((tcName) => toolchainManager.isToolchainPathReady(tcName))
245+
? CheckStatus.All_Verified
246+
: CheckStatus.All_Failed;
247247
icoPath = resManager.GetIconByName(<string>this.statusIconMap.get(status));
248248
this.provider.AddData({
249249
label: view_str$operation$setToolchainPath,
@@ -647,6 +647,13 @@ export class OperationExplorer {
647647
+ ` Loc: ${toolchainManager.getToolchainExecutableFolder('AC6')?.path}`,
648648
detail: view_str$operation$setToolchainInstallDir.replace('${name}', 'ARMCC V6 Toolchain')
649649
},
650+
{
651+
label: 'IAR ARM C/C++ Compiler',
652+
type: 'IAR_ARM',
653+
description: this.getStatusTxt(toolchainManager.isToolchainPathReady('IAR_ARM'))
654+
+ ` Loc: ${toolchainManager.getToolchainExecutableFolder('IAR_ARM')?.path}`,
655+
detail: view_str$operation$setToolchainInstallDir.replace('${name}', 'IAR ARM C/C++ Compiler')
656+
},
650657
{
651658
label: 'GNU Arm Embedded Toolchain',
652659
type: 'GCC',

src/ResManager.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,10 @@ export class ResManager extends events.EventEmitter {
362362
return File.fromArray([(<File>this.GetDir('include')).path, 'internal_headers', 'iar_stm8_intr.h']);
363363
}
364364

365+
getIarArmForceIncludeHeaders(): File {
366+
return File.fromArray([(<File>this.GetDir('include')).path, 'internal_headers', 'iar_arm_intr.h']);
367+
}
368+
365369
/* ------------------ builder and runtime ----------------- */
366370

367371
getBuilderDir(): File {

0 commit comments

Comments
 (0)