param( [string]$TemplatesRoot = "$PSScriptRoot/../newProject/SETGUI/third_party/templates", [string]$CompilerRoot = 'C:/ti/ccs1230/ccs/tools/compiler/ti-cgt-c2000_22.6.0.LTS', [string]$OutputDirectory = "$PSScriptRoot/Bin/LoggerEepromFix", [switch]$OptimizeForSize, [ValidateSet(0,1)][int]$Rs232Fifo = 1, [string]$ImageName = "UKSSTMS320F28335_logger_eeprom_fix" ) $ErrorActionPreference = 'Stop' $protocol = Join-Path (Resolve-Path -LiteralPath $TemplatesRoot).Path 'c/set-protocol' foreach ($required in @('src/ump_protocol.c', 'ports/tms320f28335/ump_tms28335.c')) { if (!(Test-Path -LiteralPath (Join-Path $protocol $required))) { throw "Missing $required in $protocol. Use templates with the UMP v3 port." } } $output = $OutputDirectory $objects = Join-Path $output 'obj' New-Item -ItemType Directory -Force -Path $objects | Out-Null $includes = @('Source/Internal/Include', 'Source/External/v120/DSP2833x_headers/include', 'Source/External/v120/DSP2833x_common/include') | ForEach-Object { "--include_path=$PSScriptRoot/$_" } $includes += @("--include_path=$CompilerRoot/include", "--include_path=$protocol", "--include_path=$protocol/ports/tms320f28335") # Match the CCS Debug configuration used for 34a95bc5. $flags = @('-v28', '-ml', '-mt', '--float_support=fpu32', '-O1', '--define=LARGE_MODEL', '--define=_DEBUG', '--symdebug:dwarf', '--abi=coffabi', '--opt_for_speed=3') $flags += "--define=RS232_USE_FIFO=$Rs232Fifo" if ($OptimizeForSize) { $flags = @($flags | Where-Object { $_ -ne '-O1' -and $_ -ne '--opt_for_speed=3' }) $flags += @('-O2', '--opt_for_speed=0') } $external = @('DSP2833x_ADC_cal.asm', 'DSP2833x_Adc.c', 'DSP2833x_CpuTimers.c', 'DSP2833x_PieCtrl.c', 'DSP2833x_SWPrioritizedDefaultIsr.c', 'DSP2833x_SWPrioritizedPieVect.c', 'DSP2833x_SysCtrl.c', 'DSP2833x_Xintf.c', 'DSP2833x_usDelay.asm') $sources = @(Get-ChildItem -LiteralPath "$PSScriptRoot/Source/Internal" -Filter '*.c' | Sort-Object Name | ForEach-Object FullName) $sources += $external | ForEach-Object { "$PSScriptRoot/Source/External/v120/DSP2833x_common/source/$_" } $sources += "$PSScriptRoot/Source/External/v120/DSP2833x_headers/source/DSP2833x_GlobalVariableDefs.c" $objectFiles = @() foreach ($source in $sources) { & "$CompilerRoot/bin/cl2000.exe" @flags @includes --compile_only "--obj_directory=$objects" $source if ($LASTEXITCODE -ne 0) { throw "Compilation failed: $source" } $objectFiles += Join-Path $objects ([IO.Path]::GetFileNameWithoutExtension($source) + '.obj') } $name = $ImageName & "$CompilerRoot/bin/cl2000.exe" @flags -z "--map_file=$output/$name.map" --stack_size=0x3f0 --warn_sections ` "--search_path=$CompilerRoot/lib" --reread_libs --entry_point=_c_int00 --rom_model ` "--output_file=$output/$name.out" @objectFiles "$PSScriptRoot/F28335.cmd" ` "$PSScriptRoot/Source/External/v120/DSP2833x_headers/cmd/DSP2833x_Headers_nonBIOS.cmd" ` "$PSScriptRoot/Libraries/rts2800_fpu32.lib" if ($LASTEXITCODE -ne 0) { throw 'Link failed' } & "$CompilerRoot/bin/hex2000.exe" "$output/$name.out" -boot -sci8 -map "$output/${name}_hex.map" -o "$output/$name.bin.pending" -b if ($LASTEXITCODE -ne 0) { throw 'Binary conversion failed' } & "$PSScriptRoot/check_firmware.ps1" -Path "$output/$name.bin.pending" -PublishPath "$output/$name.bin" Write-Output "Firmware: $output/$name.bin"