View Issue Details

IDProjectCategoryView StatusLast Update
0037336FPCRTLpublic2020-07-15 20:03
ReporterChristo Crause Assigned ToFlorian  
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionfixed 
Product Version3.3.1 
Fixed in Version3.3.1 
Summary0037336: Xtensa [patch] ESP8266 unit for FreeRTOS
DescriptionAttached file adds ESP8266 controller unit to rtl/freertos/xtensa.
TagsNo tags attached.
Fixed in Revision45784
FPCOldBugId
FPCTarget-
Attached Files

Activities

Christo Crause

2020-07-12 10:37

reporter  

esp8266.pp (2,791 bytes)   
{******************************************************************************
Startup code for xtensa-esp8266 using ESP8266_RTOS_SDK V3.3
******************************************************************************}
unit esp8266;

{$goto on}
{$macro on}

  interface

{$linklib esp8266, static}
{$linklib util, static}
{$linklib log, static}
{$linklib c_fnano, static}
{$linklib newlib, static}
{$linklib heap, static}
{$linklib vfs, static}
{$linklib esp_common, static}
{$linklib core, static}
{$linklib freertos, static}
{$linklib phy, static}
{$linklib net80211, static}
{$linklib hal, static}
{$linklib nvs_flash, static}
{$linklib rtc, static}
{$linklib spi_flash, static}
{$linklib esp_ringbuf, static}
{$linklib gcc, static}
{$linklib pp, static}
{$linklib stdc++, static}
{$linklib pthread, static}
{$linklib wpa_supplicant, static}
//{$linklib esp_event, static} // Not in V3.3
{$linklib wpa, static}  // not in master version
{$linklib lwip, static}
{$linklib mbedtls, static}

  implementation

    uses
      consoleio,heapmgr;

    var
      _stack_top: record end; public name '_stack_top';
      operatingsystem_result: longint; external name 'operatingsystem_result';

    procedure PASCALMAIN; external name 'PASCALMAIN';
    procedure putchar(c : char);external;
    function uart_rx_one_char(pRxChar: PChar): longint; 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';
      begin
        writeln;
        if operatingsystem_result <> 0 then
          writeln('Runtime error ', operatingsystem_result);

        writeln('_haltproc called...');
        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';
      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 := #0;
        uart_rx_one_char(@ACh);  // check failure?
      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.
esp8266.pp (2,791 bytes)   

Florian

2020-07-14 22:35

administrator   ~0124017

Thanks, applied.

Christo Crause

2020-07-15 20:03

reporter   ~0124060

Thanks!

Issue History

Date Modified Username Field Change
2020-07-12 10:37 Christo Crause New Issue
2020-07-12 10:37 Christo Crause File Added: esp8266.pp
2020-07-14 22:35 Florian Assigned To => Florian
2020-07-14 22:35 Florian Status new => resolved
2020-07-14 22:35 Florian Resolution open => fixed
2020-07-14 22:35 Florian Fixed in Version => 3.3.1
2020-07-14 22:35 Florian Fixed in Revision => 45784
2020-07-14 22:35 Florian FPCTarget => -
2020-07-14 22:35 Florian Note Added: 0124017
2020-07-15 20:03 Christo Crause Status resolved => closed
2020-07-15 20:03 Christo Crause Note Added: 0124060