Shop OBEX P1 Docs P2 Docs Learn Events
Powershell script for propgcc. — Parallax Forums

Powershell script for propgcc.

alatnetalatnet Posts: 80
edited 2019-08-21 04:55 in Propeller 1
Created a powershell script to essentially compile propgcc programs via command line.

example:
$files = @(
    "ext1.cpp",
    "ext2.cpp"
)

$propwarepath="D:\\Compilers\\PropWare\\share\\PropWare"

$includepaths = @(
    "-I .",
    "-I $propwarepath\include",
	"-I $propwarepath\include\c++"
)

$librarypaths = @(
    "-L .",
    "-L $propwarepath\lib\xmm-split\"
)

$libraries = @(
	"-lpropware"
)

PropCompile.ps1 -projectName "Test" -projectExt ".cpp" -compilemode "xmm" -files $files -includepaths $includepaths -librarypaths $librarypaths -libraries $libraries
<#
.SYNOPSIS

Powershell script to manage propgcc compilation.

.DESCRIPTION

Powershell script to manage propgcc compilation in an easy to use manner.

.PARAMETER clean

Cleans the directory of compiled files.

.PARAMETER dumpobj

Dumps the elf object.

.PARAMETER projectName

Project name.
This is also the main file that has the main function.
This is Mandatory!

.PARAMETER projectExt

What the extension of the main project file uses.
Can be .c, .cpp, .cogc, or .cogcpp
Defaults to .c.

.PARAMETER files

List of extra files to compile that are usually included with the main project.
Do not add headers, only .c, .cpp, .cogc, and .cogcpp
Note, this is an array!

.PARAMETER defines

List of defines to declare when compiling.
Note, this is an array!
You must prepend each entry with "-D ".

.PARAMETER compilemode

Which compile mode to use.
Valid compile modes: lmm, cmm, xmm, xmmc, cog

.PARAMETER cflags

C Flags to use when compiling c or cogc files.
Defaults to "-Os -m32bit-doubles -fno-exceptions -std=c99".
Note, this is an array!

.PARAMETER cxxflags

C++ Flags to use when compiling cpp or cogcpp files.
Defaults to "-Os -m32bit-doubles -fno-exceptions -fno-rtti -std=c++0x".
Note, this is an array!

.PARAMETER loaderflags

Loader flags for propeller-loader.
Defaults to "-s -x".
Note, this is an array!

.PARAMETER objdumpflags

Object dump flags for propeller-elf-objdump.exe.
Defaults to "-h".
Note, this is an array!

.PARAMETER includepaths

Include paths to use when compiling.
Defaults to "-I .".
Note, this is an array!
You must prepend each entry with "-I ".

.PARAMETER librarypaths

Library paths to use when compiling.
Defaults to "-L .".
Note, this is an array!
You must prepend each entry with "-L ".

.PARAMETER libraries

Libraries to use when compiling.
Defaults to "-lsimpletools".
Note, this is an array!

.PARAMETER builddir

Where to place compiled objects.
Defaults to "build/"

.PARAMETER compilerpath

Where the compilers are located.
Defaults to "C:\\'Program Files (x86)'\\SimpleIDE\\propeller-gcc\\bin\\"

.EXAMPLE

$files = @(
    "ext1.cpp",
    "ext2.cpp"
)

$propwarepath="D:\\Compilers\\PropWare\\share\\PropWare"

$includepaths = @(
    "-I .",
    "-I $propwarepath\include",
	"-I $propwarepath\include\c++"
)

$librarypaths = @(
    "-L .",
    "-L $propwarepath\lib\$compilelib\"
)

$libraries = @(
	"-lpropware"
)

PropCompile.ps1 -projectName "Test" -projectExt ".cpp" -compilemode "xmm" -compilelib "xmm-split" -files $files -includepaths $includepaths -librarypaths $librarypaths -libraries $libraries
#>

param (
    [switch]$clean,
	[switch]$dumpobj, #dump the elf file (for simpleide?)
	[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
	[string]$projectName = "", #main project name
	[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
	[string]$projectExt = ".c", #main project's extension
	[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
	[array]$files = @(),
	[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
	[array]$defines= @(),
	[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
	[string]$compilemode = "cmm", #compile mode type
	[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
	[array]$cflags = @( #c compiler flags
		"-Os",
		"-m32bit-doubles",
		"-fno-exceptions",
		"-std=c99"
	),
	[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
	[array]$cxxflags = @( #cpp compiler flags
		"-Os",
		"-m32bit-doubles",
		"-fno-exceptions",
		"-fno-rtti",
		"-std=c++0x"
	),
	[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
	[array]$loaderflags = @( #loader flags
		"-s",
		"-x"
	),
	[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
	[array]$objdumpflags = @( #obj dumper flags
		"-h"
	),
	[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
	[array]$includepaths = @( #include paths
		"-I ."
	),
	[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
	[array]$librarypaths = @( #library paths
		"-L ."
	),
	[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
	[array]$libraries = @( #libraries to use
		"-lsimpletools"
	),
	[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
	[string]$builddir="build/", #where to store the object files
	[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
	$compilerpath="C:\\'Program Files (x86)'\\SimpleIDE\\propeller-gcc\\bin\\" #where the propgcc compiler files are
)

#c compiler
$CC="propeller-elf-gcc.exe"

#cpp compiler
$CXX="propeller-elf-g++.exe"

#loader
$LOADER="propeller-load.exe"

#obj dumper
$OBJDUMP="propeller-elf-objdump.exe"

#main project file name (do not edit)
$MAINFILE="'$projectName$projectExt'"

#output project file (do not edit)
$OUTFILE="'$projectName.elf'"

#output project binary (do not edit)
$BINARYFILE="'$projectName.binary'"

#output project pex (do not edit)
$PEXFILE="'$projectName.pex'"

#for testing functions and actually managing files (do not edit)
$OUTFILE_T="$projectName.elf"
$BINARYFILE_T="$projectName.binary"
$PEXFILE_T="$projectName.pex"

#cleanup
if ($clean){
    Write-Host "Cleaning"
    if (Test-Path $builddir){
        Remove-Item $builddir -Recurse | Out-Null
    }
    if (Test-Path $OUTFILE_T){
        Remove-Item $OUTFILE_T | Out-Null
    }
    if (Test-Path $BINARYFILE_T){
        Remove-Item $BINARYFILE_T | Out-Null
    }
	if(Test-Path $PEXFILE_T){
        Remove-Item $PEXFILE_T | Out-Null
	}
    exit
}

#make build directory
if (Test-Path $builddir){
    Write-Host "Build Dir Exists"
    Remove-Item $builddir -Recurse | Out-Null
    New-Item $builddir -ItemType "directory" | Out-Null
} else {
    Write-Host "Build Dir Doesnt Exist"
    New-Item $builddir -ItemType "directory" | Out-Null
}

#remove old elf
if (Test-Path $OUTFILE_T){
    Remove-Item $OUTFILE_T
}

#remove old binary
if (Test-Path $BINARYFILE_T){
    Remove-Item $BINARYFILE_T
}

#remove old sd binary
if(Test-Path $PEXFILE_T){
    Remove-Item $PEXFILE_T | Out-Null
}

#compile a c file
function CompileC($src){
    $filename=[IO.Path]::GetFileNameWithoutExtension($file)
    $obj="$builddir$($filename).o"
    Invoke-Expression "$compilerpath$CC $defines $includepaths $librarypaths $cflags -m$compilemode -c $SRC -o $OBJ"
    return $obj
}

#compile a cpp file
function CompileCPP($src){
    $filename=[IO.Path]::GetFileNameWithoutExtension($file)
    $obj="$builddir$($filename).opp"
    Invoke-Expression "$compilerpath$CXX $defines $includepaths $librarypaths $cxxflags -m$compilemode -c $SRC -o $OBJ"
    return $obj
}

#compile a cog c file 
function CompileCogC($src){
    $filename=[IO.Path]::GetFileNameWithoutExtension($file)
    $obj="$builddir$($filename).co"
    Invoke-Expression "$compilerpath$CC $defines $includepaths $librarypaths $cflags -mcog -c $SRC -o $OBJ"
    return $obj
}

#compile a cog cpp file
function CompileCogCPP($src){
    $filename=[IO.Path]::GetFileNameWithoutExtension($file)
    $obj="$builddir$($filename).copp"
    Invoke-Expression "$compilerpath$CXX $defines $includepaths $librarypaths $cxxflags -mcog -c $SRC -o $OBJ"
    return $obj
}

#object array for when compiling the main program
$objs=@()

#compile object files
foreach($file in $files){
    $ext = [IO.Path]::GetExtension($file)
    if($ext -eq ".c"){
        Write-Host "Compiling C File: $file"
        $objs += CompileC($file)
    }elseif($ext -eq ".cpp"){
        Write-Host "Compiling CPP File: $file"
        $objs += CompileCPP($file)
    }elseif($ext -eq ".cogc"){
        Write-Host "Compiling Cog C File: $file"
        $objs += CompileCogC($file)
    }elseif($ext -eq ".cogcpp"){
        Write-Host "Compiling Cog Cpp File: $file"
        $objs += CompileCogCPP($file)
    }
}

#compile program
if($projectExt -eq ".c"){
    Write-Host "Compiling C Project"
    Invoke-Expression "$compilerpath$CC $defines $includepaths $librarypaths -o $OUTFILE $objs $CCFLAGS -m$compilemode $MAINFILE $libraries"
}elseif($projectExt -eq ".cpp"){
    Write-Host "Compiling CPP Project"
    Invoke-Expression "$compilerpath$CXX $defines$includepaths $librarypaths -o $OUTFILE $objs $cxxflags -m$compilemode $MAINFILE $libraries"
}

#make a loadable file
Invoke-Expression "$compilerpath$LOADER $loaderflags $OUTFILE"

if($dumpobj){
	#hell if i know. probably for simpletools.
	Invoke-Expression "$compilerpath$OBJDUMP $objdumpflags $OUTFILE"
}
«1

Comments

  • Well.. uh... I guess congratulations is in order. Good learning experience, I'm sure. You've created your own build system :)

    But.... have you considered using an existing build system instead of reinventing the wheel?
  • DavidZemon wrote: »
    Well.. uh... I guess congratulations is in order. Good learning experience, I'm sure. You've created your own build system :)

    But.... have you considered using an existing build system instead of reinventing the wheel?

    Would like to use makefile but since im on windows with WSL, makefiles dont seem to like the windows version of propgcc and propgcc doesnt seem to want to compile or something, i'll have to check on that.
    Dont like CMake cus of problems trying to compile a different project.
  • alatnet wrote: »
    DavidZemon wrote: »
    Well.. uh... I guess congratulations is in order. Good learning experience, I'm sure. You've created your own build system :)

    But.... have you considered using an existing build system instead of reinventing the wheel?

    Would like to use makefile but since im on windows with WSL, makefiles dont seem to like the windows version of propgcc and propgcc doesnt seem to want to compile or something, i'll have to check on that.
    Dont like CMake cus of problems trying to compile a different project.

    If running inside WSL, don't use the Windows version of PropGCC. Use the Linux version directly inside WSL. Life will be much easier that way. Treat it like a VM and do everything from within WSL - check out code, edit the code, compile the code, I think you can even load your program to the Propeller from within WSL but don't quote me on that last one.

    If you ever want to try CMake again, feel free to reach out. I've successfully integrated it into a number of different projects on both Linux and Windows and may be able to get you past whatever problem you had.
  • Well, i'll see what i can do.
    As for propeller-loader support in WSL, it should work since Com ports are mapped to /dev/ttyS<n>.
    Though may need to chmod it first or something.
    Was able to communicate to a Pi Zero W via usb serial gadget in WSL.
  • So, yea...
    Propgcc will not compile cus of binutils and texinfo...
    Tried two forks off of it but i guess my up to date version of ubuntu in WSL just will not compile them...
    On top of that, the windows release of propgcc-1.9.0-alpha doesnt generate correct binaries...
  • alatnet wrote: »
    So, yea...
    Propgcc will not compile cus of binutils and texinfo...
    Tried two forks off of it but i guess my up to date version of ubuntu in WSL just will not compile them...
    On top of that, the windows release of propgcc-1.9.0-alpha doesnt generate correct binaries...

    Hello!
    What, um. version is your UBUNTU in WSL ? I'm using a fairly recent version of SuSe, in this case its their SLES 15 (or thereabouts.)
  • Ubuntu 19.04

    uname: Linux alatnet-PC 4.4.0-17763-Microsoft #379-Microsoft Wed Mar 06 19:16:00 PST 2019 x86_64 x86_64 x86_64 GNU/Linux
    lsb_release:
    Distributor ID: Ubuntu
    Description: Ubuntu 19.04
    Release: 19.04
    Codename: disco
  • Okay, that's a recent enough bird. (That is a release.) However when did you last update your host image? The company now says that the named version is one we're stuck with, the builds on the other hand are incremental, and that yours might not still be under their support legend. I needed to update mine.

    And here's mine:
    Linux MRWORF1 4.4.0-18362-Microsoft #1-Microsoft Mon Mar 18 12:02:00 PST 2019 x86_64 x86_64 x86_64 GNU/Linux
    

    And you're not alone in that problem. I attempted to build the whole business on my older laptop who was running Slackware64-14.2 and ran into those brickwalls.

    Oh and where'd you obtain your copy of PropGCC?
  • I believe that i have the updated version, as i was able to update using these instructions: https://medium.com/@rockey5520/wsl-ubuntu-upgrade-to-disco-dingo-19-04-b4abff20452d
    Roughly.

    As for propgcc: https://github.com/parallaxinc/propgcc
    Along with some forks from there.
    There's also an issue that has patches to supposedly fix it but i dont know why they dont seem apply for me.
  • alatnet wrote: »
    I believe that i have the updated version, as i was able to update using these instructions: https://medium.com/@rockey5520/wsl-ubuntu-upgrade-to-disco-dingo-19-04-b4abff20452d
    Roughly.

    As for propgcc: https://github.com/parallaxinc/propgcc
    Along with some forks from there.
    There's also an issue that has patches to supposedly fix it but i dont know why they dont seem apply for me.

    Okay. I meant the host, your Windows 10 laptop. It might not be as up to date as the circumstances allow.
  • Windows 10 desktop version 1809.
    Latest version of windows 10 as applicable due to 1903 not released to all users yet.
  • DavidZemonDavidZemon Posts: 2,973
    edited 2019-08-24 13:44
    Building gcc is stupidly difficult, and building old versions of GCC even more so. I strongly recommend either downloading the binaries from my CI server (linked in my sig) or using these docker-based instructions: https://forums.parallax.com/discussion/168418/building-propgcc-with-docker
  • alatnetalatnet Posts: 80
    edited 2019-08-24 15:02
    well, grabbed the version off of your ci server.
    When i tried to compile my program, it's saying that it cant find libstdc++.
    D :\Compilers\propgcc-win\bin\propeller-elf-g++.exe : d :/compilers/propgcc-win/bin/../lib/gcc/propeller-elf/6.0.0/../../../../propeller-elf/bin/ld.exe: cannot find -lstdc++
    Doesnt seem to be in "propeller-elf/lib" which is where it is with the other installation of the propgcc that i have.
  • Oh, yea... That. PropGCC6 was never finished. It doesn't have the C++ standard libraries or headers :(
    If you're doing C++, you have to stick with 4
  • oh, i see the gcc4 version...
  • yep, same issue as before.
    Doesnt create a working elf/binary file.
  • Well I'm glad your original version was working! :smile:

    So what problem are you running into?
  • Dont know why, but when i tried out the propgcc4 from both your site to download it from (propware) and the ci server, it just wont make a proper elf/binary file.
    I can use the simpleIDE compilers fine and it'll create the elf/binary fine though.
    I've attached the two binary files. you can hands down tell the difference in size and in content.
    the sIDE version has readable strings where as the gcc4 version does not.

    Note, this project is to work with a YM2612 and uses an Character LCD with an I2C backpack to work.
    It displays debug information on the LCD.
  • I see they are different sizes, but they're close enough that it doesn't mean much. The version of PropGCC shipped with SimpleIDE is much older and doesn't contain all the same optimizations that were added later on.

    If you want to debug it yourself, be my quest, but if you're asking for help, we need more information. What exact commands are you using to compile, what is your code, and what's the error message that makes you say "this binary doesn't work"?
  • It's essentially a slightly modified version of my powershell script formatted to be more like a makefile.
    CPP Compiler: propeller-elf-g++.exe
    Loader: propeller-load.exe
    CPP Flags: -Os -m32bit-doubles -fno-exceptions -fno-rtti -std=c++0x
    Using propware includes and CMM library (-lpropware).

    Compiling CPP Files: $CXX $defines $includepaths $libararypaths $cxxflags -mcmm -c $SRC -o $OBJ
    Compiling the main file: $CXX $defines $includepaths $librarypaths -o $OUTFILE $objs $cxxflags -mcmm $MAINFILE $libraries
    Creating the binary file: $LOADER -s -x $OUTFILE

    What i expect it to do is display "Hello, World!" on the upper part of the LCD and "Hello propeller!" on the lower part of the LCD and then run some YM2612 test code but it doesnt do that at all.
  • Ah! I had no idea you were a PropWare user :)
    Well, I have the code downloaded and it builds "out of the box" as soon as I wrapped it with a simple CMake file. I've found an I2C "backpack" for one of my LCD displays so I'll see if I can get some things figured out.
    I've took a quick gander at the code and it all looks reasonable. I have looked at every line yet, so can you answer one quick question: it's not using more than a single cog at the moment, right? There's no extra cog start invocations buried deep in some other file (other than main.cpp), right?
  • alatnetalatnet Posts: 80
    edited 2019-08-24 21:40
    No, no additional cogs yet.
    Going to do something fancy with streaming a VGM with another cog later though, once i get the YM2612 to actually play correct sounds...
    I do like propware compared to simpleide though. works quite nicely.
  • Oh, and one more question: which version of PropWare are you using? If 3.0.0, an exact build number would be helpful (the fourth part of the version number, such as "3.0.0.223" not just "3.0.0")
  • 3.0.0.223 from the version.txt file in share/PropWare.
  • if you want, this is my powershell script to compile:
    param (
        [switch]$clean,
    	[switch]$dumpobj #dump the elf file (for simpleide?)
    )
    
    #main project name
    $projectName="main"
    
    #main project's extension
    $projectExt=".cpp"
    
    #additional files to compile.
    $files = @(
        "LiquidCrystal_I2C.cpp",
        "LTC6903.cpp",
        "YM2612.cpp",
    	"SN76489.cpp"
        #"safe_spi.cpp",
        #"fsrw.cpp"
    )
    
    #defines for the project
    $defines = @(
    	#"-DFLIPBUS"
    )
    
    #compile mode type
    $compilemode = "cmm"
    
     #which compile libary to use
    $compilelib = $compilemode
    
    #where the propgcc compiler files are
    $compilerpath="C:\\'Program Files (x86)'\\SimpleIDE\\propeller-gcc\\bin\\"
    #$compilerpath="D:\Compilers\parallax\bin\"
    #$compilerpath="D:\Compilers\propgcc-win\bin\"
    
    #where the simple tools libraries are
    $simpletoolspath="D:\\Users\\alatn\\Documents\\SimpleIDE\\Learn\\'Simple Libraries'"
    #$simpletoolspath="D:\Compilers\SimpleToolsLibs"
    
    #where the propware libraries are
    $propwarepath="D:\\Compilers\\PropWare\\share\\PropWare"
    
    #c compiler
    $CC="propeller-elf-gcc.exe"
    
    #cpp compiler
    $CXX="propeller-elf-g++.exe"
    
    #loader
    $LOADER="propeller-load.exe"
    
    #obj dumper
    $OBJDUMP="propeller-elf-objdump.exe"
    
    #c compiler flags
    $cflags = @(
        "-Os",
        "-m32bit-doubles",
        "-fno-exceptions",
        "-std=c99"
    )
    
    #cpp compiler flags
    $cxxflags = @(
        "-Os",
        "-m32bit-doubles",
        "-fno-exceptions",
        "-fno-rtti",
    	"-std=c++0x"
    )
    
    #loader flags
    $loaderflags = @(
        "-s",
    	"-x"
    	#"-p COM8",
    	#"-z",
    	#"-D sdspi-do=27",
    	#"-D sdspi-clk=26",
    	#"-D sdspi-di=25",
    	#"-D sdspi-cs=24"
    )
    
    #obj dumper flags
    $objdumpflags = @(
        "-h"
    )
    
    #include paths
    $includepaths = @(
        "-I .",
        #"-I $simpletoolspath/Protocol/libsimplei2c",
        #"-I $simpletoolspath/Utility/libsimpletools",
        #"-I $simpletoolspath/TextDevices/libsimpletext"
        "-I $propwarepath\include",
    	"-I $propwarepath\include\c++"
    )
    
    #library paths
    $librarypaths = @(
        "-L .",
        #"-L $simpletoolspath/Protocol/libsimplei2c/$compilemode/",
        #"-L $simpletoolspath/Utility/libsimpletools/$compilemode/",
        #"-L $simpletoolspath/TextDevices/libsimpletext/$compilemode/"
        "-L $propwarepath\lib\$compilelib\"
    )
    
    #libraries to use
    $libraries = @(
        #"-lm",
    	"-lpropware"
        #"-lsimple"
        #"-lsimplei2c",
        #"-lsimpletools",
        #"-lsimpletext"
    )
    
    #where to store the object files
    $builddir="build/"
    
    #main project file name (do not edit)
    $MAINFILE="'$projectName$projectExt'"
    
    #output project file (do not edit)
    $OUTFILE="'$projectName.elf'"
    
    #output project binary (do not edit)
    $BINARYFILE="'$projectName.binary'"
    
    #output project pex (do not edit)
    $PEXFILE="'$projectName.pex'"
    
    #for testing functions and actually managing files (do not edit)
    $OUTFILE_T="$projectName.elf"
    $BINARYFILE_T="$projectName.binary"
    $PEXFILE_T="$projectName.pex"
    
    #cleanup
    if ($clean){
        Write-Host "Cleaning"
        if (Test-Path $builddir){
            Remove-Item $builddir -Recurse | Out-Null
        }
        if (Test-Path $OUTFILE_T){
            Remove-Item $OUTFILE_T | Out-Null
        }
        if (Test-Path $BINARYFILE_T){
            Remove-Item $BINARYFILE_T | Out-Null
        }
    	if(Test-Path $PEXFILE_T){
            Remove-Item $PEXFILE_T | Out-Null
    	}
        exit
    }
    
    #make build directory
    if (Test-Path $builddir){
        Write-Host "Build Dir Exists"
        Remove-Item $builddir -Recurse | Out-Null
        New-Item $builddir -ItemType "directory" | Out-Null
    } else {
        Write-Host "Build Dir Doesnt Exist"
        New-Item $builddir -ItemType "directory" | Out-Null
    }
    
    #remove old elf
    if (Test-Path $OUTFILE_T){
        Remove-Item $OUTFILE_T
    }
    
    #remove old binary
    if (Test-Path $BINARYFILE_T){
        Remove-Item $BINARYFILE_T
    }
    
    #remove old sd binary
    if(Test-Path $PEXFILE_T){
        Remove-Item $PEXFILE_T | Out-Null
    }
    
    #compile a c file
    function CompileC($src){
        $filename=[IO.Path]::GetFileNameWithoutExtension($file)
        $obj="$builddir$($filename).o"
        Invoke-Expression "$compilerpath$CC $defines $includepaths $librarypaths $cflags -m$compilemode -c $SRC -o $OBJ"
        return $obj
    }
    
    #compile a cpp file
    function CompileCPP($src){
        $filename=[IO.Path]::GetFileNameWithoutExtension($file)
        $obj="$builddir$($filename).opp"
        Invoke-Expression "$compilerpath$CXX $defines $includepaths $librarypaths $cxxflags -m$compilemode -c $SRC -o $OBJ"
        return $obj
    }
    
    #compile a cog c file 
    function CompileCogC($src){
        $filename=[IO.Path]::GetFileNameWithoutExtension($file)
        $obj="$builddir$($filename).co"
        Invoke-Expression "$compilerpath$CC $defines $includepaths $librarypaths $cflags -mcog -c $SRC -o $OBJ"
        return $obj
    }
    
    #compile a cog cpp file
    function CompileCogCPP($src){
        $filename=[IO.Path]::GetFileNameWithoutExtension($file)
        $obj="$builddir$($filename).copp"
        Invoke-Expression "$compilerpath$CXX $defines $includepaths $librarypaths $cxxflags -mcog -c $SRC -o $OBJ"
        return $obj
    }
    
    #object array for when compiling the main program
    $objs=@()
    
    #compile object files
    foreach($file in $files){
        $ext = [IO.Path]::GetExtension($file)
        if($ext -eq ".c"){
            Write-Host "Compiling C File: $file"
            $objs += CompileC($file)
        }elseif($ext -eq ".cpp"){
            Write-Host "Compiling CPP File: $file"
            $objs += CompileCPP($file)
        }elseif($ext -eq ".cogc"){
            Write-Host "Compiling Cog C File: $file"
            $objs += CompileCogC($file)
        }elseif($ext -eq ".cogcpp"){
            Write-Host "Compiling Cog Cpp File: $file"
            $objs += CompileCogCPP($file)
        }
    }
    
    #compile program
    if($projectExt -eq ".c"){
        Write-Host "Compiling C Project"
        Invoke-Expression "$compilerpath$CC $defines $includepaths $librarypaths -o $OUTFILE $objs $cflags -m$compilemode $MAINFILE $libraries"
    }elseif($projectExt -eq ".cpp"){
        Write-Host "Compiling CPP Project"
        Invoke-Expression "$compilerpath$CXX $defines $includepaths $librarypaths -o $OUTFILE $objs $cxxflags -m$compilemode $MAINFILE $libraries"
    }
    
    #make a binary file
    Invoke-Expression "$compilerpath$LOADER $loaderflags $OUTFILE"
    
    if($dumpobj){
    	#hell if i know. probably for simpletools.
    	Invoke-Expression "$COMPILERPATH$OBJDUMP $objdumpflags $OUTFILE"
    }
    
  • I should note, that i might be hitting a power issue.
    I've used this breadboard power supply and a custom built power supply with a 12V ac adapter and they seem to be getting hot. On my custom one, the 5V LM1117_T -5.0 component heats up where as the 3v3 LD1117V33 is absolutely fine. Im guessing it's the same with the breadboard powersupply...

    And when i modify the YM_WRITE_WAIT and YM_RESET_WAIT to 10x or 100x, the LCD display will sometimes get garbled...
  • I've reproduced your issue, so I don't think it's just a power problem.

    Btw, you might consider extending the LiquidCrystal_I2C class to inherit from PropWare::PrintCapable, that way you can use PropWare's Printer wrapper for easier printing.
  • Found it. You can't use `usleep(1)` because that's faster than the function can execute and it ends up rolling over. I don't know exactly how long it takes to execute, but "100" is a safe minimum. You could change delayMicro() to look like this:
    if (micro < 100)
      usleep(100);
    else
      usleep(micro);
    

    Also, while searching for the problem, I updated the LiquidCrystal class to make use of the I2CMaster return codes by using the check_errors() macro everywhere.

    And finally, have you considered extending the LiquidCrystal class to implement the PropWare::PrintCapable interface? This would allow you to wrap LiquidCrystal with a PropWare::Printer object and give you really easy formatted writing.

    I've attached the updated project. Only files changed are main.cpp and the two LiquidCrystal files.
  • alatnetalatnet Posts: 80
    edited 2019-08-25 04:10
    ok, so using your modifications, it does work but im getting errors with it when trying to run it with my setup.
    Always happens on "Res." or "Playing".
    And apparently im having the opposite problem now. my propgcc installation works but the simpleide one doesnt.
    Weird...

    EDIT: If i take out the serial output code "pwOut" it works fine.

    EDIT2: ok, i might be hitting a power problem. I think it's the 5v on this breadboard power supply that i have: https://www.ebay.com/itm/Mini-USB-MB102-Breadboard-Power-Supply-Solderless-3-3V-5V-DC-7-12V-for-Arduino/263325131846
    I have the MB102 mini usb one.
    It keeps heating up really bad to the point that if i touch it, it's probably hot enough to burn or cause really bad discomfort.
  • Yea.... Various aspects of PropWare don't work with the old compiler shipped with SimpleIDE. pwOut is one I know about.

    I'm absolute rubbish with hardware, so I'll let others jump to help with power problems
Sign In or Register to comment.