Bläddra i källkod

Initial support for esp32-c6-s2-s3. Support for idf versions 5.0.6 and 5.2.1

Michael Ring 1 år sedan
förälder
incheckning
14b3c11c0d
36 ändrade filer med 1074 tillägg och 159 borttagningar
  1. 6 0
      Makefile
  2. 16 1
      compiler/options.pas
  3. 38 3
      compiler/pmodules.pas
  4. 5 1
      compiler/riscv32/cpuinfo.pas
  5. 8 8
      compiler/riscv32/nrv32util.pas
  6. 166 137
      compiler/systems/t_freertos.pas
  7. 15 5
      compiler/xtensa/cpuinfo.pas
  8. 6 0
      packages/Makefile
  9. 6 0
      packages/build/Makefile.pkg
  10. 6 0
      packages/fpmkunit/Makefile
  11. 6 0
      rtl/Makefile
  12. 38 2
      rtl/freertos/Makefile
  13. 15 2
      rtl/freertos/Makefile.fpc
  14. 84 0
      rtl/freertos/riscv32/esp32c2.pp
  15. 52 0
      rtl/freertos/riscv32/esp32c2idf_50000.pp
  16. 59 0
      rtl/freertos/riscv32/esp32c2idf_50200.pp
  17. 5 0
      rtl/freertos/riscv32/esp32c3.pp
  18. 59 0
      rtl/freertos/riscv32/esp32c3idf_50200.pp
  19. 82 0
      rtl/freertos/riscv32/esp32c6.pp
  20. 59 0
      rtl/freertos/riscv32/esp32c6idf_50200.pp
  21. 84 0
      rtl/freertos/xtensa/esp32s2.pp
  22. 84 0
      rtl/freertos/xtensa/esp32s3.pp
  23. 2 0
      rtl/freertos/xtensa/espidf_40200.pp
  24. 53 0
      rtl/freertos/xtensa/espidf_50000.pp
  25. 62 0
      rtl/freertos/xtensa/espidf_50200.pp
  26. 17 0
      rtl/inc/Makefile.rtl
  27. 3 0
      rtl/namespaced/freertos/riscv32/System.esp32c2idf_50000.pp
  28. 3 0
      rtl/namespaced/freertos/riscv32/System.esp32c2idf_50200.pp
  29. 3 0
      rtl/namespaced/freertos/riscv32/System.esp32c3idf_50200.pp
  30. 3 0
      rtl/namespaced/freertos/riscv32/System.esp32c6.pp
  31. 3 0
      rtl/namespaced/freertos/riscv32/System.esp32c6idf_50200.pp
  32. 3 0
      rtl/namespaced/freertos/xtensa/System.esp32s2.pp
  33. 3 0
      rtl/namespaced/freertos/xtensa/System.esp32s3.pp
  34. 3 0
      rtl/namespaced/freertos/xtensa/System.espidf_50000.pp
  35. 3 0
      rtl/namespaced/freertos/xtensa/System.espidf_50200.pp
  36. 14 0
      utils/dotutils/known.txt

+ 6 - 0
Makefile

@@ -227,6 +227,12 @@ $(error When compiling for xtensa-freertos, a sub-architecture (e.g. SUBARCH=lx1
 endif
 override FPCOPT+=-Cp$(SUBARCH)
 endif
+ifeq ($(CPU_OS_TARGET),riscv32-freertos)
+ifeq ($(SUBARCH),)
+$(error When compiling for riscv32-freertos, a sub-architecture (e.g. SUBARCH=rv32imc or SUBARCH=rv32imac) must be defined)
+endif
+override FPCOPT+=-Cp$(SUBARCH)
+endif
 ifeq ($(CPU_OS_TARGET),arm-freertos)
 ifeq ($(SUBARCH),)
 $(error When compiling for arm-freertos, a sub-architecture (e.g. SUBARCH=armv6m or SUBARCH=armv7em) must be defined)

+ 16 - 1
compiler/options.pas

@@ -1515,13 +1515,28 @@ begin
         set_system_compvar('IDF_VERSION','40200');
         idf_version:=40200;
       end;
+    ct_esp32s2,ct_esp32s3:
+      begin
+        set_system_compvar('IDF_VERSION','50006');
+        idf_version:=40400;
+      end;
 {$endif}
 {$ifdef RISCV32}
+    ct_esp32c2:
+      begin
+        set_system_compvar('IDF_VERSION','50006');
+        idf_version:=40400;
+      end;
     ct_esp32c3:
       begin
-        set_system_compvar('IDF_VERSION','40400');
+        set_system_compvar('IDF_VERSION','50006');
         idf_version:=40400;
       end;
+    ct_esp32c6:
+      begin
+        set_system_compvar('IDF_VERSION','50201');
+        idf_version:=50200;
+      end;
 {$endif RISCV32}
     else
       begin

+ 38 - 3
compiler/pmodules.pas

@@ -506,8 +506,23 @@ implementation
                 CheckAddUnit('espidf_40100')
               else if (idf_version>=40200) and (idf_version<40400) then
                 CheckAddUnit('espidf_40200')
-              else if idf_version>=40400 then
+              else if (idf_version>=40400) and (idf_version<50000) then
+                CheckAddUnit('espidf_40400')
+              else if (idf_version>=50000) and (idf_version<50200) then
+                CheckAddUnit('espidf_50000')
+              else if idf_version>=50200 then
+                CheckAddUnit('espidf_50200')
+              else
+                Comment(V_Warning, 'Unsupported esp-idf version');
+            end
+          else if (current_settings.controllertype=ct_esp32s2) or (current_settings.controllertype=ct_esp32s3) then
+            begin
+              if (idf_version>=40400) and (idf_version<50000) then
                 CheckAddUnit('espidf_40400')
+              else if (idf_version>=50000) and (idf_version<50200) then
+                CheckAddUnit('espidf_50000')
+              else if idf_version>=50200 then
+                CheckAddUnit('espidf_50200')
               else
                 Comment(V_Warning, 'Unsupported esp-idf version');
             end
@@ -523,16 +538,36 @@ implementation
 {$endif XTENSA}
 {$ifdef RISCV32}
         if not(curr.is_unit) and (target_info.system=system_riscv32_freertos) then
+          if (current_settings.controllertype=ct_esp32c2) then
+            begin
+              if idf_version>=50200 then
+                CheckAddUnit('esp32c2idf_50200')
+              else if idf_version>=50000 then
+                CheckAddUnit('esp32c2idf_50000')
+              else if idf_version>=40400 then
+                CheckAddUnit('esp32c2idf_40400')
+              else
+                Comment(V_Warning, 'Unsupported esp-idf version');
+            end;
           if (current_settings.controllertype=ct_esp32c3) then
             begin
-              if idf_version>=50000 then
+              if idf_version>=50200 then
+                CheckAddUnit('esp32c3idf_50200')
+              else if idf_version>=50000 then
                 CheckAddUnit('esp32c3idf_50000')
               else if idf_version>=40400 then
                 CheckAddUnit('esp32c3idf_40400')
               else
                 Comment(V_Warning, 'Unsupported esp-idf version');
             end;
-{$endif XTENSA}
+          if (current_settings.controllertype=ct_esp32c6) then
+            begin
+              if idf_version>=50200 then
+                CheckAddUnit('esp32c6idf_50200')
+              else
+                Comment(V_Warning, 'Unsupported esp-idf version');
+            end;
+{$endif RISCV32}
       end;
 
 

+ 5 - 1
compiler/riscv32/cpuinfo.pas

@@ -82,7 +82,9 @@ Type
       ct_ch32v307rc,
       ct_ch32v307wc,
       ct_ch32V307vc,
+      ct_esp32c2,
       ct_esp32c3,
+      ct_esp32c6,
       ct_CH32V0x,
       ct_CH32Vxxxx6,
       ct_CH32Vxxxx8,
@@ -139,7 +141,9 @@ Const
       (controllertypestr:'CH32V307RC'; controllerunitstr:'CH32V307';    cputype:cpu_rv32imac; fputype:fpu_fd; flashbase:$00000000; flashsize:$00040000; srambase:$20000000; sramsize:$00010000),
       (controllertypestr:'CH32V307WC'; controllerunitstr:'CH32V307';    cputype:cpu_rv32imac; fputype:fpu_fd; flashbase:$00000000; flashsize:$00040000; srambase:$20000000; sramsize:$00010000),
       (controllertypestr:'CH32V307VC'; controllerunitstr:'CH32V307';    cputype:cpu_rv32imac; fputype:fpu_fd; flashbase:$00000000; flashsize:$00040000; srambase:$20000000; sramsize:$00010000),
-      (controllertypestr:'ESP32C3'; controllerunitstr:'ESP32C3';    cputype:cpu_rv32imc; fputype:fpu_none; flashbase:$00000000; flashsize:4*1024*1024; srambase:$20000000; sramsize:400*1024),
+      (controllertypestr:'ESP32C2'; controllerunitstr:'ESP32C2';    cputype:cpu_rv32imc;  fputype:fpu_none; flashbase:$00000000; flashsize:4*1024*1024; srambase:$20000000; sramsize:272*1024),
+      (controllertypestr:'ESP32C3'; controllerunitstr:'ESP32C3';    cputype:cpu_rv32imc;  fputype:fpu_none; flashbase:$00000000; flashsize:4*1024*1024; srambase:$20000000; sramsize:400*1024),
+      (controllertypestr:'ESP32C6'; controllerunitstr:'ESP32C6';    cputype:cpu_rv32imac; fputype:fpu_none; flashbase:$00000000; flashsize:4*1024*1024; srambase:$20000000; sramsize:512*1024),
       (controllertypestr:'CH32V0X' ; controllerunitstr:'CH32VxBootstrap';   cputype:cpu_rv32e; fputype:fpu_none; flashbase:$00000000; flashsize:$00004000; srambase:$20000000; sramsize:$00000800; eeprombase:0; eepromsize:0;BootBase:$1FFFF000; BootSize:1920),
       (controllertypestr:'CH32VXXXX6' ; controllerunitstr:'CH32VxBootstrap';   cputype:cpu_rv32imac; fputype:fpu_none; flashbase:$00000000; flashsize:$00008000; srambase:$20000000; sramsize:$00002800),
       (controllertypestr:'CH32VXXXX8' ; controllerunitstr:'CH32VxBootstrap';   cputype:cpu_rv32imac; fputype:fpu_none; flashbase:$00000000; flashsize:$00010000; srambase:$20000000; sramsize:$00008000),

+ 8 - 8
compiler/riscv32/nrv32util.pas

@@ -60,13 +60,13 @@ implementation
       var
         ref: treference;
       begin
-        // addi sp,sp,-4
-        list.Concat(taicpu.op_reg_reg_const(A_ADDI,NR_STACK_POINTER_REG,NR_STACK_POINTER_REG,-4));
+        // addi sp,sp,-16
+        list.Concat(taicpu.op_reg_reg_const(A_ADDI,NR_STACK_POINTER_REG,NR_STACK_POINTER_REG,-16));
 
-        // sw ra,0(sp)
+        // sw ra,12(sp)
         reference_reset(ref,4,[]);
         ref.base:=NR_STACK_POINTER_REG;
-        ref.offset:=0;
+        ref.offset:=12;
         list.Concat(taicpu.op_reg_ref(A_SW,NR_RETURN_ADDRESS_REG,ref));
       end;
 
@@ -74,14 +74,14 @@ implementation
       var
         ref: treference;
       begin
-        // lw ra,0(sp)
+        // lw ra,12(sp)
         reference_reset(ref,4,[]);
         ref.base:=NR_STACK_POINTER_REG;
-        ref.offset:=0;
+        ref.offset:=12;
         list.Concat(taicpu.op_reg_ref(A_LW,NR_RETURN_ADDRESS_REG,ref));
 
-        // addi sp,sp,4
-        list.Concat(taicpu.op_reg_reg_const(A_ADDI,NR_STACK_POINTER_REG,NR_STACK_POINTER_REG,4));
+        // addi sp,sp,16
+        list.Concat(taicpu.op_reg_reg_const(A_ADDI,NR_STACK_POINTER_REG,NR_STACK_POINTER_REG,16));
 
         // ret
         list.Concat(taicpu.op_none(A_RET));

+ 166 - 137
compiler/systems/t_freertos.pas

@@ -91,7 +91,6 @@ begin
   Info.ExeCmd[1]:='ld -g '+platform_select+platformopt+' $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP $MAP -L. -o $EXE -T $RES';
 end;
 
-
 function TlinkerFreeRTOS.WriteResponseFile: Boolean;
 Var
   linkres  : TLinkRes;
@@ -168,7 +167,10 @@ begin
       { vlink doesn't use SEARCH_DIR for object files }
       if not(cs_link_on_target in current_settings.globalswitches) then
        s:=FindObjectFile(s,'',false);
-      LinkRes.AddFileName((maybequoted(s)));
+      if (idf_version>=50200) then
+        LinkRes.AddFileName(ExtractFileName(maybequoted(s)))
+      else
+        LinkRes.AddFileName((maybequoted(s)));
      end;
    end;
 
@@ -180,7 +182,10 @@ begin
       while not StaticLibFiles.Empty do
         begin
           S:=StaticLibFiles.GetFirst;
-          LinkRes.AddFileName((maybequoted(s)));
+          if (idf_version>=50200) then
+            LinkRes.AddFileName(ExtractFileName(maybequoted(s)))
+          else
+            LinkRes.AddFileName((maybequoted(s)));
         end;
     end;
 
@@ -1513,120 +1518,158 @@ var
   FixedExeFileName: string;
   {$if defined(XTENSA) or defined(RISCV32)}
   memory_script,
-  sections_script: AnsiString;
+  sections_script,
+  cntrlr,
+  extraopts: AnsiString;
   {$endif defined(XTENSA) or defined(RISCV32)}
 begin
-{$if defined(XTENSA) or defined(RISCV32)}
-  { idfpath can be set by -Ff, else default to environment value of IDF_PATH }
-  if idfpath='' then
-    idfpath := trim(GetEnvironmentVariable('IDF_PATH'));
-  idfpath:=ExcludeTrailingBackslash(idfpath);
-{$endif defined(XTENSA) or defined(RISCV32)}
-
   { for future use }
   StaticStr:='';
   StripStr:='';
   mapstr:='';
   DynLinkStr:='';
-
   success:=true;
   Result:=false;
+  extraopts:='';
 
-{$ifdef XTENSA}
-  { Locate linker scripts.  If not found, generate defaults. }
-  { Cater for different script names in different esp-idf versions }
+{$if defined(XTENSA) or defined(RISCV32)}
+  { idfpath can be set by -Ff, else default to environment value of IDF_PATH }
+  if idfpath='' then
+    idfpath := trim(GetEnvironmentVariable('IDF_PATH'));
+  idfpath:=ExcludeTrailingBackslash(idfpath);
 
-  if (current_settings.controllertype = ct_esp32) then
-    begin
-      if idf_version >= 40400 then
-        begin
-          memory_script := 'memory.ld';
-          sections_script := 'sections.ld';
-        end
-      else
+{$ifdef XTENSA}
+  case current_settings.controllertype of
+    ct_esp32: cntrlr:='esp32';
+    ct_esp32s2: cntrlr:='esp32s2';
+    ct_esp32s3: cntrlr:='esp32s3';
+    ct_esp8266: cntrlr:='esp8266';
+    else
+      cntrlr:='';
+  end;
+{$endif XTENSA}
+{$ifdef RISCV32}
+  case current_settings.controllertype of
+    ct_esp32c2: cntrlr:='esp32c2';
+    ct_esp32c3: cntrlr:='esp32c3';
+    ct_esp32c6:
       begin
-        memory_script := 'esp32_out.ld';
-        sections_script := 'esp32.project.ld';
-      end;
-    end
-  else if (current_settings.controllertype = ct_esp8266) then
-    begin
-     memory_script := 'esp8266_out.ld';
-     sections_script := 'esp8266.project.ld';
-    end;
-
-  if not (FindLibraryFile(memory_script,'','',memory_script) and
-         FindLibraryFile(sections_script,'','',sections_script)) then
-    GenerateDefaultLinkerScripts(memory_script,sections_script);
-
-  if (current_settings.controllertype = ct_esp32) then
-    begin
-      Info.ExeCmd[1]:=Info.ExeCmd[1]+' -u call_user_start_cpu0 -u ld_include_panic_highint_hdl -u esp_app_desc -u vfs_include_syscalls_impl -u pthread_include_pthread_impl -u pthread_include_pthread_cond_impl -u pthread_include_pthread_local_storage_impl -u newlib_include_locks_impl '+
-       '-u newlib_include_heap_impl -u newlib_include_syscalls_impl -u newlib_include_pthread_impl -u app_main -u uxTopUsedPriority '+
-       '-L $IDF_PATH/components/esp_rom/esp32/ld '+
-       '-T esp32.rom.ld -T esp32.rom.libgcc.ld -T esp32.rom.newlib-data.ld -T esp32.rom.syscalls.ld -T esp32.rom.newlib-funcs.ld '+
-       '-T '+memory_script+' -T '+sections_script;
-
-      if idf_version<40400 then
-        Info.ExeCmd[1]:=Info.ExeCmd[1]+' -L $IDF_PATH/components/esp32/ld -T esp32.peripherals.ld'
-      else
-        Info.ExeCmd[1]:=Info.ExeCmd[1]+' -L $IDF_PATH/components/soc/esp32/ld -T esp32.peripherals.ld';
-      if idf_version>=40300 then
-        Info.ExeCmd[1]:=Info.ExeCmd[1]+' -T esp32.rom.api.ld';
-      if idf_version>=40400 then
-        Info.ExeCmd[1]:=Info.ExeCmd[1]+' -T esp32.rom.newlib-time.ld';
-    end
-  else
-    begin
-      Info.ExeCmd[1] := Info.ExeCmd[1]+' -u call_user_start -u g_esp_sys_info -u _printf_float -u _scanf_float '+
-        '-L $IDF_PATH/components/esp8266/ld -T esp8266.peripherals.ld -T esp8266.rom.ld '+ { SDK scripts }
-        '-T '+memory_script+' -T '+sections_script; { Project scripts }
+        cntrlr:='esp32c6';
+        { Extra option required to generate bin file }
+        extraopts:=' --flash-mmu-page-size 32KB ';
+      end
+    else
+      cntrlr:='';
     end;
+{$endif RISCV32}
 
-  Replace(Info.ExeCmd[1],'$IDF_PATH',idfpath);
-{$endif XTENSA}
-
-{$ifdef RISCV32}
   { Locate linker scripts.  If not found, generate defaults. }
   { Cater for different script names in different esp-idf versions }
-
-  if (current_settings.controllertype = ct_esp32c3) then
+  if idf_version >= 40400 then
     begin
-      if idf_version >= 40400 then
-        begin
-          memory_script := 'memory.ld';
-          sections_script := 'sections.ld';
-        end
-      else
-      begin
-        memory_script := 'esp32c3_out.ld';
-        sections_script := 'esp32c3.project.ld';
-      end;
-    end;
+      memory_script := 'memory.ld';
+      sections_script := 'sections.ld';
+    end
+  else
+  begin
+    memory_script := cntrlr+'_out.ld';
+    sections_script := cntrlr+'.project.ld';
+  end;
 
   if not (FindLibraryFile(memory_script,'','',memory_script) and
          FindLibraryFile(sections_script,'','',sections_script)) then
     GenerateDefaultLinkerScripts(memory_script,sections_script);
 
-  if (current_settings.controllertype = ct_esp32c3) then
+{$ifdef XTENSA}
+    if (current_settings.controllertype=ct_esp8266) then
+      begin
+       Info.ExeCmd[1] := Info.ExeCmd[1]+' -u call_user_start -u g_esp_sys_info -u _printf_float -u _scanf_float '+
+         '-L $IDF_PATH/components/'+cntrlr+'/ld -T '+cntrlr+'.peripherals.ld -T '+cntrlr+'.rom.ld '+ { SDK scripts }
+         '-T '+memory_script+' -T '+sections_script; { Project scripts }
+      end
+    else
+{$endif XTENSA}
     begin
       Info.ExeCmd[1]:=Info.ExeCmd[1]+' -u call_user_start_cpu0 -u ld_include_panic_highint_hdl -u esp_app_desc -u vfs_include_syscalls_impl -u pthread_include_pthread_impl -u pthread_include_pthread_cond_impl -u pthread_include_pthread_local_storage_impl -u newlib_include_locks_impl '+
        '-u newlib_include_heap_impl -u newlib_include_syscalls_impl -u newlib_include_pthread_impl -u app_main -u uxTopUsedPriority '+
-       '-T '+memory_script+' -T '+sections_script+' '+
-       '-L $IDF_PATH/components/esp_rom/esp32c3/ld '+
-       '-T esp32c3.rom.ld -T esp32c3.rom.libgcc.ld -T esp32c3.rom.newlib.ld -T esp32c3.rom.eco3.ld  -T esp32c3.rom.version.ld ';
-
-      if idf_version>=40300 then
-        Info.ExeCmd[1]:=Info.ExeCmd[1]+' -T esp32c3.rom.api.ld';
-
+       '-L $IDF_PATH/components/esp_rom/'+cntrlr+'/ld ';
       if idf_version<40400 then
-        Info.ExeCmd[1]:=Info.ExeCmd[1]+' -L $IDF_PATH/components/esp32c3/ld -T esp32c3.peripherals.ld'
+        Info.ExeCmd[1]:=Info.ExeCmd[1]+' -L $IDF_PATH/components/'+cntrlr+'/ld'
       else
-        Info.ExeCmd[1]:=Info.ExeCmd[1]+' -L $IDF_PATH/components/soc/esp32c3/ld -T esp32c3.peripherals.ld';
-    end;
+        Info.ExeCmd[1]:=Info.ExeCmd[1]+' -L $IDF_PATH/components/soc/'+cntrlr+'/ld';
 
+      Info.ExeCmd[1]:=Info.ExeCmd[1]+' -T '+memory_script+' -T '+sections_script;
+      Info.ExeCmd[1]:=Info.ExeCmd[1]+' -T '+cntrlr+'.rom.ld -T '+cntrlr+'.rom.api.ld';
+{$ifdef XTENSA}
+      if current_settings.controllertype = ct_esp32 then
+        if idf_version>=50200 then
+          Info.ExeCmd[1]:=Info.ExeCmd[1]+' -T '+cntrlr+'.rom.libgcc.ld -T '+cntrlr+'.rom.newlib-data.ld -T '+cntrlr+'.rom.syscalls.ld -T '+cntrlr+'.rom.newlib-funcs.ld'
+        else if idf_version>=50000 then
+          Info.ExeCmd[1]:=Info.ExeCmd[1]+' -T '+cntrlr+'.rom.libgcc.ld -T '+cntrlr+'.rom.newlib-data.ld -T '+cntrlr+'.rom.syscalls.ld -T '+cntrlr+'.rom.newlib-funcs.ld'
+        else if idf_version>=40400 then
+          Info.ExeCmd[1]:=Info.ExeCmd[1]+' -T '+cntrlr+'.rom.libgcc.ld -T '+cntrlr+'.rom.newlib-data.ld -T '+cntrlr+'.rom.syscalls.ld -T '+cntrlr+'.rom.newlib-funcs.ld -T '+cntrlr+'.rom.newlib-time.ld'
+        else if idf_version>=40300 then
+          Info.ExeCmd[1]:=Info.ExeCmd[1]+' -T '+cntrlr+'.rom.libgcc.ld -T '+cntrlr+'.rom.newlib-data.ld -T '+cntrlr+'.rom.syscalls.ld -T '+cntrlr+'.rom.newlib-funcs.ld -T '+cntrlr+'.rom.newlib-time.ld'
+        else
+          begin
+            //Currently not supported
+          end;
+      if current_settings.controllertype = ct_esp32s2 then
+        if idf_version>=50200 then
+          Info.ExeCmd[1]:=Info.ExeCmd[1]+' -T '+cntrlr+'.rom.libgcc.ld -T '+cntrlr+'.rom.newlib-funcs.ld -T '+cntrlr+'.rom.newlib-data.ld -T '+cntrlr+'.rom.spiflash.ld'
+        else if idf_version>=50000 then
+          Info.ExeCmd[1]:=Info.ExeCmd[1]+' -T '+cntrlr+'.rom.libgcc.ld -T '+cntrlr+'.rom.newlib-funcs.ld -T '+cntrlr+'.rom.newlib-data.ld -T '+cntrlr+'.rom.spiflash.ld'
+        else if idf_version>=40400 then
+          Info.ExeCmd[1]:=Info.ExeCmd[1]+' -T '+cntrlr+'.rom.libgcc.ld -T '+cntrlr+'.rom.newlib-funcs.ld -T '+cntrlr+'.rom.newlib-data.ld -T '+cntrlr+'.rom.spiflash.ld -T '+cntrlr+'.rom.newlib-time.ld'
+        else
+          begin
+            //Currently not supported
+          end;
+      if current_settings.controllertype = ct_esp32s3 then
+        if idf_version>=50200 then
+          Info.ExeCmd[1]:=Info.ExeCmd[1]+' -T '+cntrlr+'.rom.libgcc.ld -T '+cntrlr+'.rom.newlib.ld -T '+cntrlr+'.rom.version.ld'
+        else if idf_version>=50000 then
+          Info.ExeCmd[1]:=Info.ExeCmd[1]+' -T '+cntrlr+'.rom.libgcc.ld -T '+cntrlr+'.rom.newlib.ld -T '+cntrlr+'.rom.version.ld'
+        else if idf_version>=40400 then
+          Info.ExeCmd[1]:=Info.ExeCmd[1]+' -T '+cntrlr+'.rom.libgcc.ld -T '+cntrlr+'.rom.newlib.ld -T '+cntrlr+'.rom.version.ld -T '+cntrlr+'.rom.newlib-time.ld'
+        else
+          begin
+            //Currently not supported
+          end;
+  {$endif XTENSA}
+  {$ifdef RISCV32}
+      if current_settings.controllertype=ct_esp32c2 then
+        if idf_version>=50200 then
+          Info.ExeCmd[1]:=Info.ExeCmd[1]+' -T '+cntrlr+'.rom.rvfp.ld -T '+cntrlr+'.rom.newlib.ld -T '+cntrlr+'.rom.version.ld -T '+cntrlr+'.rom.newlib-nano.ld -T '+cntrlr+'.rom.heap.ld'
+        else if idf_version>=50000 then
+          Info.ExeCmd[1]:=Info.ExeCmd[1]+' -T '+cntrlr+'.rom.rvfp.ld -T '+cntrlr+'.rom.newlib.ld -T '+cntrlr+'.rom.version.ld -T '+cntrlr+'.rom.newlib-time.ld -T '+cntrlr+'.rom.newlib-nano.ld -T '+cntrlr+'.rom.heap.ld'
+        else 
+          begin
+            //Currently not supported
+          end;
+      if current_settings.controllertype=ct_esp32c3 then
+        if idf_version>=50200 then
+          Info.ExeCmd[1]:=Info.ExeCmd[1]+' -T '+cntrlr+'.rom.libgcc.ld -T '+cntrlr+'.rom.newlib.ld  -T '+cntrlr+'.rom.version.ld -T '+cntrlr+'.rom.eco3.ld'
+        else if idf_version>=50000 then
+          Info.ExeCmd[1]:=Info.ExeCmd[1]+' -T '+cntrlr+'.rom.libgcc.ld -T '+cntrlr+'.rom.newlib.ld  -T '+cntrlr+'.rom.version.ld -T '+cntrlr+'.rom.eco3.ld'
+        else if idf_version>=40400 then
+          Info.ExeCmd[1]:=Info.ExeCmd[1]+' -T '+cntrlr+'.rom.libgcc.ld -T '+cntrlr+'.rom.newlib.ld  -T '+cntrlr+'.rom.version.ld  -T '+cntrlr+'.rom.newlib-time.ld -T '+cntrlr+'.rom.eco3.ld'
+        else
+          begin
+            //Currently not supported
+          end;
+      if current_settings.controllertype=ct_esp32c6 then
+        if idf_version>=50200 then
+          Info.ExeCmd[1]:=Info.ExeCmd[1]+' -T '+cntrlr+'.rom.rvfp.ld -T '+cntrlr+'.rom.newlib.ld -T '+cntrlr+'.rom.version.ld -T '+cntrlr+'.rom.phy.ld -T '+cntrlr+'.rom.coexist.ld -T '+cntrlr+'.rom.net80211.ld -T '+cntrlr+'.rom.pp.ld -T '+cntrlr+'.rom.wdt.ld -T '+cntrlr+'.rom.systimer.ld -T '+cntrlr+'.rom.newlib-normal.ld -T '+cntrlr+'.rom.heap.ld'
+        else
+          begin
+          //Currently not supported
+          end;
+  {$endif RISCV32}
+      Info.ExeCmd[1]:=Info.ExeCmd[1]+' -T '+cntrlr+'.peripherals.ld'
+    end;
   Replace(Info.ExeCmd[1],'$IDF_PATH',idfpath);
-{$endif RISCV32}
+{$endif defined(XTENSA) or defined(RISCV32)}
 
   FixedExeFileName:=maybequoted(ScriptFixFileName(ChangeFileExt(current_module.exefilename,'.elf')));
 
@@ -1673,61 +1716,47 @@ begin
   if success and not(cs_link_nolink in current_settings.globalswitches) then
     success:=PostProcessExecutable(FixedExeFileName,false);
 
+{$if defined(XTENSA) or defined(RISCV32)}
   if success then
-   begin
-{$ifndef ARM}
+    begin
 {$if defined(DARWIN)}
-     success:=FindFileInExeLocations('python',true,binstr);
-     cmdstr:=idfpath+'/components/esptool_py/esptool/esptool.py ';
+      success:=FindFileInExeLocations('python',true,binstr);
+      cmdstr:=idfpath+'/components/esptool_py/esptool/esptool.py ';
 {$elseif defined(UNIX)}
-     binstr:=TargetFixPath(idfpath,false)+'/components/esptool_py/esptool/esptool.py';
-     cmdstr:='';
+      binstr:=TargetFixPath(idfpath,false)+'/components/esptool_py/esptool/esptool.py';
+      cmdstr:='';
 {$else}
-     binstr:='python';
-     cmdstr:=idfpath+'/components/esptool_py/esptool/esptool.py ';
+      binstr:='python';
+      cmdstr:=idfpath+'/components/esptool_py/esptool/esptool.py ';
 {$endif UNIX}
-{$endif ARM}
 
-{$if defined(XTENSA)}
-     if source_info.exeext<>'' then
-       binstr:=binstr+source_info.exeext;
-     if (current_settings.controllertype = ct_esp32) then
-       begin
-         success:=DoExec(binstr,cmdstr+'--chip esp32 elf2image --flash_mode dio --flash_freq 40m '+
-           '--flash_size '+tostr(embedded_controllers[current_settings.controllertype].flashsize div (1024*1024))+'MB '+
-           '--elf-sha256-offset 0xb0 '+
-           '-o '+maybequoted(ScriptFixFileName(ChangeFileExt(current_module.exefilename,'.bin')))+' '+
-           FixedExeFileName,
-           true,false);
-       end
-     else if (current_settings.controllertype = ct_esp8266) then
-       begin
-         success:=DoExec(binstr,cmdstr+'--chip esp8266 elf2image --flash_mode dout --flash_freq 40m '+
-           '--flash_size '+tostr(embedded_controllers[current_settings.controllertype].flashsize div (1024*1024))+'MB '+
-           '--version=3 '+
-           '-o '+maybequoted(ScriptFixFileName(ChangeFileExt(current_module.exefilename,'.bin')))+' '+
-           FixedExeFileName,
-           true,false);
-       end
-{$elseif defined(RISCV32)}
-     if source_info.exeext<>'' then
-       binstr:=binstr+source_info.exeext;
-     if (current_settings.controllertype = ct_esp32c3) then
-       begin
-         success:=DoExec(binstr,cmdstr+'--chip esp32c3 elf2image --flash_mode dio --flash_freq 80m '+
-           '--flash_size '+tostr(embedded_controllers[current_settings.controllertype].flashsize div (1024*1024))+'MB '+
-           '--elf-sha256-offset 0xb0 --min-rev 3 '+
-           '-o '+maybequoted(ScriptFixFileName(ChangeFileExt(current_module.exefilename,'.bin')))+' '+
-           FixedExeFileName,
-           true,false);
-       end;
-{$endif defined(RISCV32)}
-   end
-  else
-    if success then
-      success:=DoExec(FindUtil(utilsprefix+'objcopy'),'-O binary '+
-        FixedExeFileName+' '+
-        maybequoted(ScriptFixFileName(ChangeFileExt(current_module.exefilename,'.bin'))),true,false);
+{$ifdef XTENSA}
+      if (current_settings.controllertype = ct_esp8266) then
+        begin
+          success:=DoExec(binstr,cmdstr+'--chip esp8266 elf2image --flash_mode dout --flash_freq 40m '+
+            '--flash_size '+tostr(embedded_controllers[current_settings.controllertype].flashsize div (1024*1024))+'MB '+
+            '--version=3 '+
+            '-o '+maybequoted(ScriptFixFileName(ChangeFileExt(current_module.exefilename,'.bin')))+' '+
+            FixedExeFileName,
+            true,false);
+        end
+      else
+{$endif XTENSA}
+        begin
+          success:=DoExec(binstr,cmdstr+'--chip '+cntrlr+' elf2image '+
+            '--flash_size '+tostr(embedded_controllers[current_settings.controllertype].flashsize div (1024*1024))+'MB '+
+            '--elf-sha256-offset 0xb0 '+extraopts+
+            '-o '+maybequoted(ScriptFixFileName(ChangeFileExt(current_module.exefilename,'.bin')))+' '+
+            FixedExeFileName,
+            true,false);
+        end;
+    end;
+{$else}
+  if success then
+    success:=DoExec(FindUtil(utilsprefix+'objcopy'),'-O binary '+
+      FixedExeFileName+' '+
+      maybequoted(ScriptFixFileName(ChangeFileExt(current_module.exefilename,'.bin'))),true,false);
+{$endif defined(XTENSA) or defined(RISCV32)}
 
   MakeExecutable:=success;   { otherwise a recursive call to link method }
 end;

+ 15 - 5
compiler/xtensa/cpuinfo.pas

@@ -37,7 +37,9 @@ Type
    tcputype =
       (cpu_none,
        cpu_lx106,
-       cpu_lx6
+       cpu_lx6,
+       cpu_lx7,
+       cpu_lx7hf
       );
 
 
@@ -56,7 +58,9 @@ Type
       ct_esp32,
       ct_esp32_d0wd,
       ct_esp32_d2wd,
-      ct_esp32_sOwd
+      ct_esp32_sOwd,
+      ct_esp32s2,
+      ct_esp32s3
      );
 
    tcontrollerdatatype = record
@@ -92,7 +96,9 @@ Const
    cputypestr : array[tcputype] of string[8] = (
      '',
      'LX106',
-     'LX6'
+     'LX6',
+     'LX7',
+     'LX7HF'
    );
 
    fputypestr : array[tfputype] of string[10] = (
@@ -114,7 +120,9 @@ Const
       (controllertypestr:'ESP32';	controllerunitstr:'ESP32';	cputype:cpu_lx6; fputype:fpu_hard; abi: abi_xtensa_windowed; flashbase:$40000000; flashsize:2*1024*1024),
       (controllertypestr:'ESP32_D0WD';	controllerunitstr:'ESP32_D0WD';	cputype:cpu_lx6; fputype:fpu_hard; abi: abi_xtensa_windowed; flashbase:$40000000; flashsize:448*1024; srambase:$40070000; sramsize: 520*1024),
       (controllertypestr:'ESP32_D2WD';	controllerunitstr:'ESP32_D2WD';	cputype:cpu_lx6; fputype:fpu_hard; abi: abi_xtensa_windowed; flashbase:$40000000; flashsize:448*1024; srambase:$40070000; sramsize: 520*1024),
-      (controllertypestr:'ESP32_S0WD';	controllerunitstr:'ESP32_S0WD';	cputype:cpu_lx6; fputype:fpu_hard; abi: abi_xtensa_windowed; flashbase:$40000000; flashsize:448*1024; srambase:$40070000; sramsize: 520*1024)
+      (controllertypestr:'ESP32_S0WD';	controllerunitstr:'ESP32_S0WD';	cputype:cpu_lx6; fputype:fpu_hard; abi: abi_xtensa_windowed; flashbase:$40000000; flashsize:448*1024; srambase:$40070000; sramsize: 520*1024),
+      (controllertypestr:'ESP32S2';	controllerunitstr:'ESP32S2';	cputype:cpu_lx7; fputype:fpu_soft; abi: abi_xtensa_windowed; flashbase:$40000000; flashsize:4*1024*1024),
+      (controllertypestr:'ESP32S3';	controllerunitstr:'ESP32S3';	cputype:cpu_lx7hf; fputype:fpu_hard; abi: abi_xtensa_windowed; flashbase:$40000000; flashsize:4*1024*1024)
    );
 
    { Supported optimizations, only used for information }
@@ -156,7 +164,9 @@ Const
      (
        { cpu_none     } [],
        { cpu_lx106    } [],
-       { cpu_lx6      } [CPUXTENSA_REGWINDOW, CPUXTENSA_HAS_SEXT, CPUXTENSA_HAS_NSAx, CPUXTENSA_HAS_BOOLEAN_OPTION, CPUXTENSA_HAS_MUL32HIGH, CPUXTENSA_HAS_DIV, CPUXTENSA_HAS_LOOPS, CPUXTENSA_HAS_MINMAX]
+       { cpu_lx6      } [CPUXTENSA_REGWINDOW, CPUXTENSA_HAS_SEXT, CPUXTENSA_HAS_NSAx, CPUXTENSA_HAS_BOOLEAN_OPTION, CPUXTENSA_HAS_MUL32HIGH, CPUXTENSA_HAS_DIV, CPUXTENSA_HAS_LOOPS, CPUXTENSA_HAS_MINMAX],
+       { cpu_lxf      } [CPUXTENSA_REGWINDOW, CPUXTENSA_HAS_SEXT, CPUXTENSA_HAS_NSAx, CPUXTENSA_HAS_BOOLEAN_OPTION, CPUXTENSA_HAS_MUL32HIGH, CPUXTENSA_HAS_DIV, CPUXTENSA_HAS_MINMAX],
+       { cpu_lx7hf    } [CPUXTENSA_REGWINDOW, CPUXTENSA_HAS_SEXT, CPUXTENSA_HAS_NSAx, CPUXTENSA_HAS_BOOLEAN_OPTION, CPUXTENSA_HAS_MUL32HIGH, CPUXTENSA_HAS_DIV, CPUXTENSA_HAS_MINMAX]
      );
 
    fpu_capabilities : array[tfputype] of set of tfpuflags =

+ 6 - 0
packages/Makefile

@@ -227,6 +227,12 @@ $(error When compiling for xtensa-freertos, a sub-architecture (e.g. SUBARCH=lx1
 endif
 override FPCOPT+=-Cp$(SUBARCH)
 endif
+ifeq ($(CPU_OS_TARGET),riscv32-freertos)
+ifeq ($(SUBARCH),)
+$(error When compiling for riscv32-freertos, a sub-architecture (e.g. SUBARCH=rv32imc or SUBARCH=rv32imac) must be defined)
+endif
+override FPCOPT+=-Cp$(SUBARCH)
+endif
 ifeq ($(CPU_OS_TARGET),arm-freertos)
 ifeq ($(SUBARCH),)
 $(error When compiling for arm-freertos, a sub-architecture (e.g. SUBARCH=armv6m or SUBARCH=armv7em) must be defined)

+ 6 - 0
packages/build/Makefile.pkg

@@ -227,6 +227,12 @@ $(error When compiling for xtensa-freertos, a sub-architecture (e.g. SUBARCH=lx1
 endif
 override FPCOPT+=-Cp$(SUBARCH)
 endif
+ifeq ($(CPU_OS_TARGET),riscv32-freertos)
+ifeq ($(SUBARCH),)
+$(error When compiling for riscv32-freertos, a sub-architecture (e.g. SUBARCH=rv32imc or SUBARCH=rv32imac) must be defined)
+endif
+override FPCOPT+=-Cp$(SUBARCH)
+endif
 ifeq ($(CPU_OS_TARGET),arm-freertos)
 ifeq ($(SUBARCH),)
 $(error When compiling for arm-freertos, a sub-architecture (e.g. SUBARCH=armv6m or SUBARCH=armv7em) must be defined)

+ 6 - 0
packages/fpmkunit/Makefile

@@ -227,6 +227,12 @@ $(error When compiling for xtensa-freertos, a sub-architecture (e.g. SUBARCH=lx1
 endif
 override FPCOPT+=-Cp$(SUBARCH)
 endif
+ifeq ($(CPU_OS_TARGET),riscv32-freertos)
+ifeq ($(SUBARCH),)
+$(error When compiling for riscv32-freertos, a sub-architecture (e.g. SUBARCH=rv32imc or SUBARCH=rv32imac) must be defined)
+endif
+override FPCOPT+=-Cp$(SUBARCH)
+endif
 ifeq ($(CPU_OS_TARGET),arm-freertos)
 ifeq ($(SUBARCH),)
 $(error When compiling for arm-freertos, a sub-architecture (e.g. SUBARCH=armv6m or SUBARCH=armv7em) must be defined)

+ 6 - 0
rtl/Makefile

@@ -227,6 +227,12 @@ $(error When compiling for xtensa-freertos, a sub-architecture (e.g. SUBARCH=lx1
 endif
 override FPCOPT+=-Cp$(SUBARCH)
 endif
+ifeq ($(CPU_OS_TARGET),riscv32-freertos)
+ifeq ($(SUBARCH),)
+$(error When compiling for riscv32-freertos, a sub-architecture (e.g. SUBARCH=rv32imc or SUBARCH=rv32imac) must be defined)
+endif
+override FPCOPT+=-Cp$(SUBARCH)
+endif
 ifeq ($(CPU_OS_TARGET),arm-freertos)
 ifeq ($(SUBARCH),)
 $(error When compiling for arm-freertos, a sub-architecture (e.g. SUBARCH=armv6m or SUBARCH=armv7em) must be defined)

+ 38 - 2
rtl/freertos/Makefile

@@ -228,6 +228,12 @@ $(error When compiling for xtensa-freertos, a sub-architecture (e.g. SUBARCH=lx1
 endif
 override FPCOPT+=-Cp$(SUBARCH)
 endif
+ifeq ($(CPU_OS_TARGET),riscv32-freertos)
+ifeq ($(SUBARCH),)
+$(error When compiling for riscv32-freertos, a sub-architecture (e.g. SUBARCH=rv32imc or SUBARCH=rv32imac) must be defined)
+endif
+override FPCOPT+=-Cp$(SUBARCH)
+endif
 ifeq ($(CPU_OS_TARGET),arm-freertos)
 ifeq ($(SUBARCH),)
 $(error When compiling for arm-freertos, a sub-architecture (e.g. SUBARCH=armv6m or SUBARCH=armv7em) must be defined)
@@ -452,15 +458,23 @@ EMU387UNIT=DOSApi.EMU387
 EMXUNIT=DOSApi.EMX
 ERRORSUNIT=UnixApi.Errors
 ESP32UNIT=System.Esp32
+ESP32C2UNIT=System.Esp32c2
 ESP32C3UNIT=System.Esp32c3
+ESP32C6UNIT=System.Esp32c6
+ESP32C2IDF_50000UNIT=System.Esp32c2idf_50000
+ESP32C2IDF_50200UNIT=System.Esp32c2idf_50200
 ESP32C3IDF_40400UNIT=System.Esp32c3idf_40400
 ESP32C3IDF_50000UNIT=System.Esp32c3idf_50000
+ESP32C3IDF_50200UNIT=System.Esp32c3idf_50200
+ESP32C6IDF_50200UNIT=System.Esp32c6idf_50200
 ESP8266UNIT=System.Esp8266
 ESP8266RTOS_30300UNIT=System.Esp8266rtos_30300
 ESP8266RTOS_30400UNIT=System.Esp8266rtos_30400
 ESPIDF_40100UNIT=System.Espidf_40100
 ESPIDF_40200UNIT=System.Espidf_40200
 ESPIDF_40400UNIT=System.Espidf_40400
+ESPIDF_50000UNIT=System.Espidf_50000
+ESPIDF_50200UNIT=System.Espidf_50200
 EXEUNIT=OS2Api.exe
 EXEINFOUNIT=System.ExeInfo
 EXTPASUNIT=extpas
@@ -704,15 +718,24 @@ EMU387UNIT=emu387
 EMXUNIT=emx
 ERRORSUNIT=errors
 ESP32UNIT=esp32
+ESP32S2UNIT=esp32s2
+ESP32S3UNIT=esp32s3
+ESP32C2UNIT=esp32c2
 ESP32C3UNIT=esp32c3
+ESP32C6UNIT=esp32c6
+ESP32C2IDF_50000UNIT=esp32c2idf_50000
+ESP32C2IDF_50200UNIT=esp32c2idf_50200
 ESP32C3IDF_40400UNIT=esp32c3idf_40400
 ESP32C3IDF_50000UNIT=esp32c3idf_50000
+ESP32C6IDF_50200UNIT=esp32c6idf_50200
 ESP8266UNIT=esp8266
 ESP8266RTOS_30300UNIT=esp8266rtos_30300
 ESP8266RTOS_30400UNIT=esp8266rtos_30400
 ESPIDF_40100UNIT=espidf_40100
 ESPIDF_40200UNIT=espidf_40200
 ESPIDF_40400UNIT=espidf_40400
+ESPIDF_50000UNIT=espidf_50000
+ESPIDF_50200UNIT=espidf_50200
 EXEUNIT=exe
 EXEINFOUNIT=exeinfo
 EXTPASUNIT=extpas
@@ -928,7 +951,12 @@ ifeq ($(ARCH),riscv32)
 CPU_SPECIFIC_COMMON_UNITS=$(SYSUTILSUNIT) $(MATHUNIT) $(CLASSESUNIT) $(FGLUNIT) $(MACPASUNIT) $(TYPINFOUNIT) $(TYPESUNIT) $(RTLCONSTSUNIT) $(GETOPTSUNIT) $(LINEINFOUNIT)
 ifeq ($(SUBARCH),rv32imc)
 override FPCOPT+=-Cprv32imc
-CPU_UNITS=esp32c3 esp32c3idf_40400 esp32c3idf_50000
+CPU_UNITS=esp32c2 esp32c3 esp32c3idf_40400 esp32c2idf_50000 esp32c3idf_50000 esp32c2idf_50200 esp32c3idf_50200
+CPU_UNITS_DEFINED=1
+endif
+ifeq ($(SUBARCH),rv32imac)
+override FPCOPT+=-Cprv32imac
+CPU_UNITS=esp32c6 esp32c6idf_50200
 CPU_UNITS_DEFINED=1
 endif
 ifeq ($(CPU_UNITS_DEFINED),)
@@ -938,7 +966,15 @@ endif
 ifeq ($(ARCH),xtensa)
 CPU_SPECIFIC_COMMON_UNITS=$(SYSUTILSUNIT) $(MATHUNIT) $(CLASSESUNIT) $(FGLUNIT) $(MACPASUNIT) $(TYPINFOUNIT) $(TYPESUNIT) $(RTLCONSTSUNIT) $(GETOPTSUNIT) $(LINEINFOUNIT)
 ifeq ($(SUBARCH),lx6)
-CPU_UNITS=esp32 espidf_40100 espidf_40200 espidf_40400
+CPU_UNITS=esp32 espidf_40100 espidf_40200 espidf_40400 espidf_50000 espidf_50200
+CPU_UNITS_DEFINED=1
+endif
+ifeq ($(SUBARCH),lx7hf)
+CPU_UNITS=esp32s3 espidf_40400 espidf_50000 espidf_50200
+CPU_UNITS_DEFINED=1
+endif
+ifeq ($(SUBARCH),lx7)
+CPU_UNITS=esp32s2 espidf_40400 espidf_50000 espidf_50200
 CPU_UNITS_DEFINED=1
 endif
 ifeq ($(SUBARCH),lx106)

+ 15 - 2
rtl/freertos/Makefile.fpc

@@ -82,7 +82,12 @@ ifeq ($(ARCH),riscv32)
 CPU_SPECIFIC_COMMON_UNITS=$(SYSUTILSUNIT) $(MATHUNIT) $(CLASSESUNIT) $(FGLUNIT) $(MACPASUNIT) $(TYPINFOUNIT) $(TYPESUNIT) $(RTLCONSTSUNIT) $(GETOPTSUNIT) $(LINEINFOUNIT)
 ifeq ($(SUBARCH),rv32imc)
 override FPCOPT+=-Cprv32imc
-CPU_UNITS=esp32c3 esp32c3idf_40400 esp32c3idf_50000
+CPU_UNITS=esp32c2 esp32c3 esp32c3idf_40400 esp32c2idf_50000 esp32c3idf_50000 esp32c2idf_50200 esp32c3idf_50200
+CPU_UNITS_DEFINED=1
+endif
+ifeq ($(SUBARCH),rv32imac)
+override FPCOPT+=-Cprv32imac
+CPU_UNITS=esp32c6 esp32c6idf_50200
 CPU_UNITS_DEFINED=1
 endif
 ifeq ($(CPU_UNITS_DEFINED),)
@@ -93,7 +98,15 @@ endif
 ifeq ($(ARCH),xtensa)
 CPU_SPECIFIC_COMMON_UNITS=$(SYSUTILSUNIT) $(MATHUNIT) $(CLASSESUNIT) $(FGLUNIT) $(MACPASUNIT) $(TYPINFOUNIT) $(TYPESUNIT) $(RTLCONSTSUNIT) $(GETOPTSUNIT) $(LINEINFOUNIT)
 ifeq ($(SUBARCH),lx6)
-CPU_UNITS=esp32 espidf_40100 espidf_40200 espidf_40400
+CPU_UNITS=esp32 espidf_40100 espidf_40200 espidf_40400 espidf_50000 espidf_50200
+CPU_UNITS_DEFINED=1
+endif
+ifeq ($(SUBARCH),lx7hf)
+CPU_UNITS=esp32s3 espidf_40400 espidf_50000 espidf_50200
+CPU_UNITS_DEFINED=1
+endif
+ifeq ($(SUBARCH),lx7)
+CPU_UNITS=esp32s2 espidf_40400 espidf_50000 espidf_50200
 CPU_UNITS_DEFINED=1
 endif
 ifeq ($(SUBARCH),lx106)

+ 84 - 0
rtl/freertos/riscv32/esp32c2.pp

@@ -0,0 +1,84 @@
+{******************************************************************************
+Startup code for riscv32-esp32c2 using idf
+
+******************************************************************************}
+{$IFNDEF FPC_DOTTEDUNITS}
+unit esp32c2;
+{$ENDIF FPC_DOTTEDUNITS}
+
+{$goto on}
+{$macro on}
+
+  interface
+
+  implementation
+
+{$IFDEF FPC_DOTTEDUNITS}
+    uses
+      EmbeddedApi.ConsoleIO,EmbeddedApi.HeapMGR;
+{$ELSE FPC_DOTTEDUNITS}
+    uses
+      consoleio,heapmgr;
+{$ENDIF FPC_DOTTEDUNITS}
+
+    var
+      _stack_top: record end; public name '_stack_top';
+      operatingsystem_result: longint; external name 'operatingsystem_result';
+
+    procedure PASCALMAIN; external name 'PASCALMAIN';
+
+    procedure esp_deep_sleep_start;external;
+    procedure putchar(c : char);external;
+    function getchar : char;external;
+    function __getreent : pointer;external;
+    procedure fflush(f : pointer);external;
+    procedure vTaskDelay(xTicksToDelay: uint32); external;
+
+    procedure flushOutput(var t : TextRec);
+      begin
+        fflush(ppointer(__getreent+8)^);
+      end;
+
+
+    procedure _FPC_haltproc; public name '_haltproc';noreturn;
+      begin
+        if operatingsystem_result <> 0 then
+          writeln('Runtime error ', operatingsystem_result);
+
+        writeln('_haltproc called, exit code: ',operatingsystem_result);
+        flushOutput(TextRec(Output));
+        repeat
+          // Allow other tasks to run
+          // Do not enter deep sleep, can lead to problems with flashing
+          vTaskDelay(1000);
+        until false;
+      end;
+
+
+    procedure app_main;public name 'app_main';noreturn;
+      begin
+        PASCALMAIN;
+        _FPC_haltproc;
+      end;
+
+
+    function WriteChar(ACh: char; AUserData: pointer): boolean;
+      begin
+        WriteChar:=true;
+        putchar(ACh);
+      end;
+
+
+    function ReadChar(var ACh: char; AUserData: pointer): boolean;
+      begin
+        ReadChar:=true;
+        ACh:=getchar;
+      end;
+
+begin
+  OpenIO(Input, @WriteChar, @ReadChar, fmInput, nil);
+  OpenIO(Output, @WriteChar, @ReadChar, fmOutput, nil);
+  OpenIO(ErrOutput, @WriteChar, @ReadChar, fmOutput, nil);
+  OpenIO(StdOut, @WriteChar, @ReadChar, fmOutput, nil);
+  OpenIO(StdErr, @WriteChar, @ReadChar, fmOutput, nil);
+end.

+ 52 - 0
rtl/freertos/riscv32/esp32c2idf_50000.pp

@@ -0,0 +1,52 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2021 by Florian Klaempfl
+    member of the Free Pascal development team.
+
+    System unit for FreeRTOS systems
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+{$IFNDEF FPC_DOTTEDUNITS}
+unit esp32c2idf_50000;
+{$ENDIF FPC_DOTTEDUNITS}
+
+interface
+
+{$linklib app_update,static}
+{$linklib bootloader_support,static}
+{$linklib core,static}
+{$linklib driver,static}
+{$linklib efuse,static}
+{$linklib esp_app_format,static}
+{$linklib esp_common,static}
+{$linklib esp_hw_support,static}
+{$linklib esp_partition,static}
+{$linklib esp_pm,static}
+{$linklib esp_ringbuf,static}
+{$linklib esp_rom,static}
+{$linklib esp_system,static}
+{$linklib esp_timer,static}
+{$linklib freertos,static}
+{$linklib hal,static}
+{$linklib heap,static}
+{$linklib log,static}
+{$linklib newlib,static}
+{$linklib pthread,static}
+{$linklib riscv,static}
+{$linklib soc,static}
+{$linklib spi_flash,static}
+{$linklib vfs,static}
+{$linklib c,static}
+{$linklib m,static}
+{$linklib gcc,static}
+
+implementation
+
+end.

+ 59 - 0
rtl/freertos/riscv32/esp32c2idf_50200.pp

@@ -0,0 +1,59 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2021 by Florian Klaempfl
+    member of the Free Pascal development team.
+
+    System unit for FreeRTOS systems
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+{$IFNDEF FPC_DOTTEDUNITS}
+unit esp32c2idf_50200;
+{$ENDIF FPC_DOTTEDUNITS}
+
+interface
+
+{$linklib app_update,static}
+{$linklib bootloader_support,static}
+{$linklib coexist,static}
+{$linklib core,static}
+{$linklib driver,static}
+{$linklib efuse,static}
+{$linklib esp_app_format,static}
+{$linklib esp_coex,static}
+{$linklib esp_common,static}
+{$linklib esp_hw_support,static}
+{$linklib esp_mm,static}
+{$linklib esp_partition,static}
+{$linklib esp_phy,static}
+{$linklib esp_pm,static}
+{$linklib esp_ringbuf,static}
+{$linklib esp_rom,static}
+{$linklib esp_system,static}
+{$linklib esp_timer,static}
+{$linklib freertos,static}
+{$linklib hal,static}
+{$linklib heap,static}
+{$linklib log,static}
+{$linklib newlib,static}
+{$linklib pthread,static}
+{$linklib riscv,static}
+{$linklib soc,static}
+{$linklib spi_flash,static}
+{$linklib vfs,static}
+{$linklib c,static}
+{$linklib m,static}
+{$linklib gcc,static}
+
+{$linklib esp_gdbstub,static}
+{$linklib espcoredump,static}
+
+implementation
+
+end.

+ 5 - 0
rtl/freertos/riscv32/esp32c3.pp

@@ -13,8 +13,13 @@ unit esp32c3;
 
   implementation
 
+{$IFDEF FPC_DOTTEDUNITS}
+    uses
+      EmbeddedApi.ConsoleIO,EmbeddedApi.HeapMGR;
+{$ELSE FPC_DOTTEDUNITS}
     uses
       consoleio,heapmgr;
+{$ENDIF FPC_DOTTEDUNITS}
 
     var
       _stack_top: record end; public name '_stack_top';

+ 59 - 0
rtl/freertos/riscv32/esp32c3idf_50200.pp

@@ -0,0 +1,59 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2021 by Florian Klaempfl
+    member of the Free Pascal development team.
+
+    System unit for FreeRTOS systems
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+{$IFNDEF FPC_DOTTEDUNITS}
+unit esp32c3idf_50200;
+{$ENDIF FPC_DOTTEDUNITS}
+
+interface
+
+{$linklib app_update,static}
+{$linklib bootloader_support,static}
+{$linklib coexist,static}
+{$linklib core,static}
+{$linklib driver,static}
+{$linklib efuse,static}
+{$linklib esp_app_format,static}
+{$linklib esp_coex,static}
+{$linklib esp_common,static}
+{$linklib esp_hw_support,static}
+{$linklib esp_mm,static}
+{$linklib esp_partition,static}
+{$linklib esp_phy,static}
+{$linklib esp_pm,static}
+{$linklib esp_ringbuf,static}
+{$linklib esp_rom,static}
+{$linklib esp_system,static}
+{$linklib esp_timer,static}
+{$linklib freertos,static}
+{$linklib hal,static}
+{$linklib heap,static}
+{$linklib log,static}
+{$linklib newlib,static}
+{$linklib pthread,static}
+{$linklib riscv,static}
+{$linklib soc,static}
+{$linklib spi_flash,static}
+{$linklib vfs,static}
+{$linklib c,static}
+{$linklib m,static}
+{$linklib gcc,static}
+
+{$linklib esp_gdbstub,static}
+{$linklib espcoredump,static}
+
+implementation
+
+end.

+ 82 - 0
rtl/freertos/riscv32/esp32c6.pp

@@ -0,0 +1,82 @@
+{******************************************************************************
+Startup code for riscv32-esp32c6 using idf
+
+******************************************************************************}
+unit esp32c6;
+
+{$goto on}
+{$macro on}
+
+  interface
+
+  implementation
+
+{$IFDEF FPC_DOTTEDUNITS}
+    uses
+      EmbeddedApi.ConsoleIO,EmbeddedApi.HeapMGR;
+{$ELSE FPC_DOTTEDUNITS}
+    uses
+      consoleio,heapmgr;
+{$ENDIF FPC_DOTTEDUNITS}
+
+    var
+      _stack_top: record end; public name '_stack_top';
+      operatingsystem_result: longint; external name 'operatingsystem_result';
+
+    procedure PASCALMAIN; external name 'PASCALMAIN';
+
+    procedure esp_deep_sleep_start;external;
+    procedure putchar(c : char);external;
+    function getchar : char;external;
+    function __getreent : pointer;external;
+    procedure fflush(f : pointer);external;
+    procedure vTaskDelay(xTicksToDelay: uint32); external;
+
+    procedure flushOutput(var t : TextRec);
+      begin
+        fflush(ppointer(__getreent+8)^);
+      end;
+
+
+    procedure _FPC_haltproc; public name '_haltproc';noreturn;
+      begin
+        if operatingsystem_result <> 0 then
+          writeln('Runtime error ', operatingsystem_result);
+
+        writeln('_haltproc called, exit code: ',operatingsystem_result);
+        flushOutput(TextRec(Output));
+        repeat
+          // Allow other tasks to run
+          // Do not enter deep sleep, can lead to problems with flashing
+          vTaskDelay(1000);
+        until false;
+      end;
+
+
+    procedure app_main;public name 'app_main';noreturn;
+      begin
+        PASCALMAIN;
+        _FPC_haltproc;
+      end;
+
+
+    function WriteChar(ACh: char; AUserData: pointer): boolean;
+      begin
+        WriteChar:=true;
+        putchar(ACh);
+      end;
+
+
+    function ReadChar(var ACh: char; AUserData: pointer): boolean;
+      begin
+        ReadChar:=true;
+        ACh:=getchar;
+      end;
+
+begin
+  OpenIO(Input, @WriteChar, @ReadChar, fmInput, nil);
+  OpenIO(Output, @WriteChar, @ReadChar, fmOutput, nil);
+  OpenIO(ErrOutput, @WriteChar, @ReadChar, fmOutput, nil);
+  OpenIO(StdOut, @WriteChar, @ReadChar, fmOutput, nil);
+  OpenIO(StdErr, @WriteChar, @ReadChar, fmOutput, nil);
+end.

+ 59 - 0
rtl/freertos/riscv32/esp32c6idf_50200.pp

@@ -0,0 +1,59 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2021 by Florian Klaempfl
+    member of the Free Pascal development team.
+
+    System unit for FreeRTOS systems
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+{$IFNDEF FPC_DOTTEDUNITS}
+unit esp32c6idf_50200;
+{$ENDIF FPC_DOTTEDUNITS}
+
+interface
+
+{$linklib app_update,static}
+{$linklib bootloader_support,static}
+{$linklib coexist,static}
+{$linklib core,static}
+{$linklib driver,static}
+{$linklib efuse,static}
+{$linklib esp_app_format,static}
+{$linklib esp_coex,static}
+{$linklib esp_common,static}
+{$linklib esp_hw_support,static}
+{$linklib esp_mm,static}
+{$linklib esp_partition,static}
+{$linklib esp_phy,static}
+{$linklib esp_pm,static}
+{$linklib esp_ringbuf,static}
+{$linklib esp_rom,static}
+{$linklib esp_system,static}
+{$linklib esp_timer,static}
+{$linklib freertos,static}
+{$linklib hal,static}
+{$linklib heap,static}
+{$linklib log,static}
+{$linklib newlib,static}
+{$linklib pthread,static}
+{$linklib riscv,static}
+{$linklib soc,static}
+{$linklib spi_flash,static}
+{$linklib vfs,static}
+{$linklib c,static}
+{$linklib m,static}
+{$linklib gcc,static}
+
+{$linklib esp_gdbstub,static}
+{$linklib espcoredump,static}
+
+implementation
+
+end.

+ 84 - 0
rtl/freertos/xtensa/esp32s2.pp

@@ -0,0 +1,84 @@
+{******************************************************************************
+Startup code for xtensa-esp32s2 using idf
+
+******************************************************************************}
+{$IFNDEF FPC_DOTTEDUNITS}
+unit esp32s2;
+{$ENDIF FPC_DOTTEDUNITS}
+
+{$goto on}
+{$macro on}
+
+  interface
+
+  implementation
+
+{$IFDEF FPC_DOTTEDUNITS}
+    uses
+      EmbeddedApi.ConsoleIO,EmbeddedApi.HeapMGR;
+{$ELSE FPC_DOTTEDUNITS}
+    uses
+      consoleio,heapmgr;
+{$ENDIF FPC_DOTTEDUNITS}
+
+    var
+      _stack_top: record end; public name '_stack_top';
+      operatingsystem_result: longint; external name 'operatingsystem_result';
+
+    procedure PASCALMAIN; external name 'PASCALMAIN';
+
+    procedure esp_deep_sleep_start;external;
+    procedure putchar(c : AnsiChar);external;
+    function getchar : AnsiChar;external;
+    function __getreent : pointer;external;
+    procedure fflush(f : pointer);external;
+    procedure vTaskDelay(xTicksToDelay: uint32); external;
+
+    procedure flushOutput(var t : TextRec);
+      begin
+        fflush(ppointer(__getreent+8)^);
+      end;
+
+
+    procedure _FPC_haltproc; public name '_haltproc';noreturn;
+      begin
+        if operatingsystem_result <> 0 then
+          writeln('Runtime error ', operatingsystem_result);
+
+        writeln('_haltproc called, exit code: ',operatingsystem_result);
+        flushOutput(TextRec(Output));
+        repeat
+          // Allow other tasks to run
+          // Do not enter deep sleep, can lead to problems with flashing
+          vTaskDelay(1000);
+        until false;
+      end;
+
+
+    procedure app_main;public name 'app_main';noreturn;
+      begin
+        PASCALMAIN;
+        _FPC_haltproc;
+      end;
+
+
+    function WriteChar(ACh: AnsiChar; AUserData: pointer): boolean;
+      begin
+        WriteChar:=true;
+        putchar(ACh);
+      end;
+
+
+    function ReadChar(var ACh: AnsiChar; AUserData: pointer): boolean;
+      begin
+        ReadChar:=true;
+        ACh:=getchar;
+      end;
+
+begin
+  OpenIO(Input, @WriteChar, @ReadChar, fmInput, nil);
+  OpenIO(Output, @WriteChar, @ReadChar, fmOutput, nil);
+  OpenIO(ErrOutput, @WriteChar, @ReadChar, fmOutput, nil);
+  OpenIO(StdOut, @WriteChar, @ReadChar, fmOutput, nil);
+  OpenIO(StdErr, @WriteChar, @ReadChar, fmOutput, nil);
+end.

+ 84 - 0
rtl/freertos/xtensa/esp32s3.pp

@@ -0,0 +1,84 @@
+{******************************************************************************
+Startup code for xtensa-esp32s3 using idf
+
+******************************************************************************}
+{$IFNDEF FPC_DOTTEDUNITS}
+unit esp32s3;
+{$ENDIF FPC_DOTTEDUNITS}
+
+{$goto on}
+{$macro on}
+
+  interface
+
+  implementation
+
+{$IFDEF FPC_DOTTEDUNITS}
+    uses
+      EmbeddedApi.ConsoleIO,EmbeddedApi.HeapMGR;
+{$ELSE FPC_DOTTEDUNITS}
+    uses
+      consoleio,heapmgr;
+{$ENDIF FPC_DOTTEDUNITS}
+
+    var
+      _stack_top: record end; public name '_stack_top';
+      operatingsystem_result: longint; external name 'operatingsystem_result';
+
+    procedure PASCALMAIN; external name 'PASCALMAIN';
+
+    procedure esp_deep_sleep_start;external;
+    procedure putchar(c : AnsiChar);external;
+    function getchar : AnsiChar;external;
+    function __getreent : pointer;external;
+    procedure fflush(f : pointer);external;
+    procedure vTaskDelay(xTicksToDelay: uint32); external;
+
+    procedure flushOutput(var t : TextRec);
+      begin
+        fflush(ppointer(__getreent+8)^);
+      end;
+
+
+    procedure _FPC_haltproc; public name '_haltproc';noreturn;
+      begin
+        if operatingsystem_result <> 0 then
+          writeln('Runtime error ', operatingsystem_result);
+
+        writeln('_haltproc called, exit code: ',operatingsystem_result);
+        flushOutput(TextRec(Output));
+        repeat
+          // Allow other tasks to run
+          // Do not enter deep sleep, can lead to problems with flashing
+          vTaskDelay(1000);
+        until false;
+      end;
+
+
+    procedure app_main;public name 'app_main';noreturn;
+      begin
+        PASCALMAIN;
+        _FPC_haltproc;
+      end;
+
+
+    function WriteChar(ACh: AnsiChar; AUserData: pointer): boolean;
+      begin
+        WriteChar:=true;
+        putchar(ACh);
+      end;
+
+
+    function ReadChar(var ACh: AnsiChar; AUserData: pointer): boolean;
+      begin
+        ReadChar:=true;
+        ACh:=getchar;
+      end;
+
+begin
+  OpenIO(Input, @WriteChar, @ReadChar, fmInput, nil);
+  OpenIO(Output, @WriteChar, @ReadChar, fmOutput, nil);
+  OpenIO(ErrOutput, @WriteChar, @ReadChar, fmOutput, nil);
+  OpenIO(StdOut, @WriteChar, @ReadChar, fmOutput, nil);
+  OpenIO(StdErr, @WriteChar, @ReadChar, fmOutput, nil);
+end.

+ 2 - 0
rtl/freertos/xtensa/espidf_40200.pp

@@ -20,6 +20,8 @@ unit espidf_40200;
 interface
 
 {$linklib esp32,static}
+{$linklib coexist,static}
+{$linklib esp_wifi,static}
 {$linklib soc,static}
 {$linklib driver,static}
 {$linklib freertos,static}

+ 53 - 0
rtl/freertos/xtensa/espidf_50000.pp

@@ -0,0 +1,53 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2021 by Florian Klaempfl
+    member of the Free Pascal development team.
+
+    System unit for FreeRTOS systems
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+{$IFNDEF FPC_DOTTEDUNITS}
+unit espidf_50000;
+{$ENDIF FPC_DOTTEDUNITS}
+
+interface
+
+{$linklib app_update,static}
+{$linklib bootloader_support,static}
+{$linklib core,static}
+{$linklib driver,static}
+{$linklib efuse,static}
+{$linklib esp_app_format,static}
+{$linklib esp_common,static}
+{$linklib esp_hw_support,static}
+{$linklib esp_partition,static}
+{$linklib esp_pm,static}
+{$linklib esp_ringbuf,static}
+{$linklib esp_rom,static}
+{$linklib esp_system,static}
+{$linklib esp_timer,static}
+{$linklib freertos,static}
+{$linklib hal,static}
+{$linklib xt_hal.a,static}
+{$linklib heap,static}
+{$linklib log,static}
+{$linklib newlib,static}
+{$linklib pthread,static}
+{$linklib xtensa,static}
+{$linklib soc,static}
+{$linklib spi_flash,static}
+{$linklib vfs,static}
+{$linklib c,static}
+{$linklib m,static}
+{$linklib gcc,static}
+
+implementation
+
+end.

+ 62 - 0
rtl/freertos/xtensa/espidf_50200.pp

@@ -0,0 +1,62 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2021 by Florian Klaempfl
+    member of the Free Pascal development team.
+
+    System unit for FreeRTOS systems
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+{$IFNDEF FPC_DOTTEDUNITS}
+unit espidf_50200;
+{$ENDIF FPC_DOTTEDUNITS}
+
+interface
+
+{$linklib app_update,static}
+{$linklib bootloader_support,static}
+//{$linklib core,static}
+{$linklib coexist,static}
+{$linklib cxx,static}
+{$linklib driver,static}
+{$linklib efuse,static}
+{$linklib esp_app_format,static}
+{$linklib esp_coex,static}
+{$linklib esp_common,static}
+{$linklib esp_hw_support,static}
+{$linklib esp_mm,static}
+{$linklib esp_partition,static}
+{$linklib esp_phy,static}
+//{$linklib esp_pm,static}
+{$linklib esp_ringbuf,static}
+{$linklib esp_rom,static}
+{$linklib esp_system,static}
+{$linklib esp_timer,static}
+{$linklib freertos,static}
+{$linklib hal,static}
+{$linklib heap,static}
+{$linklib log,static}
+{$linklib mbedcrypto,static}
+{$linklib newlib,static}
+{$linklib pthread,static}
+{$linklib soc,static}
+{$linklib spi_flash,static}
+{$linklib vfs,static}
+{$linklib xt_hal.a,static}
+{$linklib xtensa,static}
+
+{$linklib c,static}
+{$linklib m,static}
+{$linklib gcc,static}
+{$linklib esp_gdbstub,static}
+{$linklib espcoredump,static}
+
+implementation
+
+end.

+ 17 - 0
rtl/inc/Makefile.rtl

@@ -94,15 +94,23 @@ EMU387UNIT=DOSApi.EMU387
 EMXUNIT=DOSApi.EMX
 ERRORSUNIT=UnixApi.Errors
 ESP32UNIT=System.Esp32
+ESP32C2UNIT=System.Esp32c2
 ESP32C3UNIT=System.Esp32c3
+ESP32C6UNIT=System.Esp32c6
+ESP32C2IDF_50000UNIT=System.Esp32c2idf_50000
+ESP32C2IDF_50200UNIT=System.Esp32c2idf_50200
 ESP32C3IDF_40400UNIT=System.Esp32c3idf_40400
 ESP32C3IDF_50000UNIT=System.Esp32c3idf_50000
+ESP32C3IDF_50200UNIT=System.Esp32c3idf_50200
+ESP32C6IDF_50200UNIT=System.Esp32c6idf_50200
 ESP8266UNIT=System.Esp8266
 ESP8266RTOS_30300UNIT=System.Esp8266rtos_30300
 ESP8266RTOS_30400UNIT=System.Esp8266rtos_30400
 ESPIDF_40100UNIT=System.Espidf_40100
 ESPIDF_40200UNIT=System.Espidf_40200
 ESPIDF_40400UNIT=System.Espidf_40400
+ESPIDF_50000UNIT=System.Espidf_50000
+ESPIDF_50200UNIT=System.Espidf_50200
 EXEUNIT=OS2Api.exe
 EXEINFOUNIT=System.ExeInfo
 EXTPASUNIT=extpas
@@ -352,15 +360,24 @@ EMU387UNIT=emu387
 EMXUNIT=emx
 ERRORSUNIT=errors
 ESP32UNIT=esp32
+ESP32S2UNIT=esp32s2
+ESP32S3UNIT=esp32s3
+ESP32C2UNIT=esp32c2
 ESP32C3UNIT=esp32c3
+ESP32C6UNIT=esp32c6
+ESP32C2IDF_50000UNIT=esp32c2idf_50000
+ESP32C2IDF_50200UNIT=esp32c2idf_50200
 ESP32C3IDF_40400UNIT=esp32c3idf_40400
 ESP32C3IDF_50000UNIT=esp32c3idf_50000
+ESP32C6IDF_50200UNIT=esp32c6idf_50200
 ESP8266UNIT=esp8266
 ESP8266RTOS_30300UNIT=esp8266rtos_30300
 ESP8266RTOS_30400UNIT=esp8266rtos_30400
 ESPIDF_40100UNIT=espidf_40100
 ESPIDF_40200UNIT=espidf_40200
 ESPIDF_40400UNIT=espidf_40400
+ESPIDF_50000UNIT=espidf_50000
+ESPIDF_50200UNIT=espidf_50200
 EXEUNIT=exe
 EXEINFOUNIT=exeinfo
 EXTPASUNIT=extpas

+ 3 - 0
rtl/namespaced/freertos/riscv32/System.esp32c2idf_50000.pp

@@ -0,0 +1,3 @@
+unit System.esp32c2idf_50000;
+{$DEFINE FPC_DOTTEDUNITS}
+{$i esp32c2idf_50000.pp}

+ 3 - 0
rtl/namespaced/freertos/riscv32/System.esp32c2idf_50200.pp

@@ -0,0 +1,3 @@
+unit System.esp32c2idf_50200;
+{$DEFINE FPC_DOTTEDUNITS}
+{$i esp32c2idf_50200.pp}

+ 3 - 0
rtl/namespaced/freertos/riscv32/System.esp32c3idf_50200.pp

@@ -0,0 +1,3 @@
+unit System.esp32c3idf_50200;
+{$DEFINE FPC_DOTTEDUNITS}
+{$i esp32c3idf_50200.pp}

+ 3 - 0
rtl/namespaced/freertos/riscv32/System.esp32c6.pp

@@ -0,0 +1,3 @@
+unit System.esp32c6;
+{$DEFINE FPC_DOTTEDUNITS}
+{$i esp32c6.pp}

+ 3 - 0
rtl/namespaced/freertos/riscv32/System.esp32c6idf_50200.pp

@@ -0,0 +1,3 @@
+unit System.esp32c6idf_50200;
+{$DEFINE FPC_DOTTEDUNITS}
+{$i esp32c6idf_50200.pp}

+ 3 - 0
rtl/namespaced/freertos/xtensa/System.esp32s2.pp

@@ -0,0 +1,3 @@
+unit System.esp32s2;
+{$DEFINE FPC_DOTTEDUNITS}
+{$i esp32s2.pp}

+ 3 - 0
rtl/namespaced/freertos/xtensa/System.esp32s3.pp

@@ -0,0 +1,3 @@
+unit System.esp32s3;
+{$DEFINE FPC_DOTTEDUNITS}
+{$i esp32s3.pp}

+ 3 - 0
rtl/namespaced/freertos/xtensa/System.espidf_50000.pp

@@ -0,0 +1,3 @@
+unit System.espidf_50000;
+{$DEFINE FPC_DOTTEDUNITS}
+{$i espidf_50000.pp}

+ 3 - 0
rtl/namespaced/freertos/xtensa/System.espidf_50200.pp

@@ -0,0 +1,3 @@
+unit System.espidf_50200;
+{$DEFINE FPC_DOTTEDUNITS}
+{$i espidf_50200.pp}

+ 14 - 0
utils/dotutils/known.txt

@@ -2463,12 +2463,26 @@ EMU387=DOSApi
 EMX=DOSApi
 Errors=UnixApi
 esp32=System
+esp32s2=System
+esp32s3=System
+esp32c2=System
+esp32c3=System
+esp32c6=System
 esp8266=System
 esp8266rtos_30300=System
 esp8266rtos_30400=System
 espidf_40100=System
 espidf_40200=System
 espidf_40400=System
+espidf_50000=System
+espidf_50200=System
+esp32c2idf_40400=System
+esp32c2idf_50000=System
+esp32c2idf_50200=System
+esp32c3idf_40400=System
+esp32c3idf_50000=System
+esp32c3idf_50200=System
+esp32c6idf_50200=System
 exe=OS2Api
 exeinfo=*System.ExeInfo
 fe310g000=EmbeddedApi