30179df8e6
Remove the fixed pseudorange start offset, preserve per-PRN navigation assistance across RF loss and power cycles, and seed coherent navigation measurement phase on reacquisition. Add full LNAV almanac visibility scheduling, power-safe QSPI journaling, RF-domain reset isolation, and PPS Gray CDC hardening with Linux, sanitizer, RTL, and end-to-end coverage.
85 lines
4.0 KiB
Tcl
85 lines
4.0 KiB
Tcl
set script_dir [file dirname [file normalize [info script]]]
|
|
set fpga_dir [file normalize [file join $script_dir ../..]]
|
|
|
|
proc getenv_default {name default} {
|
|
if {[info exists ::env($name)] && $::env($name) ne ""} {
|
|
return $::env($name)
|
|
}
|
|
return $default
|
|
}
|
|
|
|
proc region_end {offset file} {
|
|
return [expr {$offset + [file size $file]}]
|
|
}
|
|
|
|
set bit_file [file normalize [getenv_default BIT_FILE [file join $fpga_dir out bitstream genesys2_rocket.bit]]]
|
|
set app_image [file normalize [getenv_default APP_FLASH_IMAGE [file join $fpga_dir out flash hello_uart.flash.bin]]]
|
|
set bitstream_mcs [file normalize [getenv_default BITSTREAM_MCS [file join $fpga_dir out flash regions bitstream.mcs]]]
|
|
set app_mcs [file normalize [getenv_default APP_MCS [file join $fpga_dir out flash regions app.mcs]]]
|
|
set flash_size_mb [getenv_default FLASH_SIZE_MB 32]
|
|
set flash_interface [getenv_default FLASH_INTERFACE SPIx4]
|
|
set bitstream_offset [getenv_default BITSTREAM_OFFSET 0x00000000]
|
|
set app_flash_offset [getenv_default APP_FLASH_OFFSET 0x01800000]
|
|
set assistance_flash_offset [getenv_default ASSISTANCE_FLASH_OFFSET 0x01f80000]
|
|
set assistance_flash_size [getenv_default ASSISTANCE_FLASH_SIZE 0x00080000]
|
|
set region_names [split [getenv_default FLASH_REGION_NAMES "bitstream;app"] ";"]
|
|
set flash_size_bytes [expr {$flash_size_mb * 1024 * 1024}]
|
|
set assistance_end [expr {$assistance_flash_offset + $assistance_flash_size}]
|
|
if {$assistance_end > $flash_size_bytes} {
|
|
error [format "GPS assistance reservation exceeds flash: end=0x%08x flash_size=0x%08x" $assistance_end $flash_size_bytes]
|
|
}
|
|
|
|
foreach region $region_names {
|
|
if {$region eq ""} {
|
|
continue
|
|
} elseif {$region eq "bitstream"} {
|
|
if {![file exists $bit_file]} {
|
|
error "Bitstream not found: $bit_file"
|
|
}
|
|
set bitstream_end [region_end $bitstream_offset $bit_file]
|
|
if {$bitstream_end > $flash_size_bytes} {
|
|
error [format "Bitstream region exceeds flash: end=0x%08x flash_size=0x%08x" $bitstream_end $flash_size_bytes]
|
|
}
|
|
if {$bitstream_end > $app_flash_offset} {
|
|
error [format "Bitstream region crosses APP_FLASH_OFFSET: bit_end=0x%08x app_offset=0x%08x" \
|
|
$bitstream_end $app_flash_offset]
|
|
}
|
|
if {$bitstream_offset < $assistance_end && $assistance_flash_offset < $bitstream_end} {
|
|
error [format "Bitstream overlaps GPS assistance reservation: bit=[0x%08x,0x%08x) assistance=[0x%08x,0x%08x)" \
|
|
$bitstream_offset $bitstream_end $assistance_flash_offset $assistance_end]
|
|
}
|
|
file mkdir [file dirname $bitstream_mcs]
|
|
puts "Generating bitstream region MCS:"
|
|
puts " bitstream: $bit_file @ $bitstream_offset"
|
|
puts [format " flash size: 0x%08x bytes" $flash_size_bytes]
|
|
puts [format " bitstream end: 0x%08x" $bitstream_end]
|
|
write_cfgmem -force -format MCS -size $flash_size_mb -interface $flash_interface \
|
|
-loadbit "up $bitstream_offset $bit_file" \
|
|
$bitstream_mcs
|
|
puts "Wrote $bitstream_mcs"
|
|
} elseif {$region eq "app"} {
|
|
if {![file exists $app_image]} {
|
|
error "Application flash image not found: $app_image"
|
|
}
|
|
set app_end [region_end $app_flash_offset $app_image]
|
|
if {$app_end > $flash_size_bytes} {
|
|
error [format "App region exceeds flash: end=0x%08x flash_size=0x%08x" $app_end $flash_size_bytes]
|
|
}
|
|
if {$app_flash_offset < $assistance_end && $assistance_flash_offset < $app_end} {
|
|
error [format "App overlaps GPS assistance reservation: app=[0x%08x,0x%08x) assistance=[0x%08x,0x%08x)" \
|
|
$app_flash_offset $app_end $assistance_flash_offset $assistance_end]
|
|
}
|
|
file mkdir [file dirname $app_mcs]
|
|
puts "Generating app region MCS:"
|
|
puts " app image: $app_image @ $app_flash_offset"
|
|
puts [format " flash size: 0x%08x bytes" $flash_size_bytes]
|
|
puts [format " app end: 0x%08x" $app_end]
|
|
write_cfgmem -force -format MCS -size $flash_size_mb -interface $flash_interface \
|
|
-loaddata "up $app_flash_offset $app_image" \
|
|
$app_mcs
|
|
puts "Wrote $app_mcs"
|
|
} else {
|
|
error "Unknown flash region: $region"
|
|
}
|
|
}
|