Skip to content

Commit

Permalink
Polarfire SD-MUX flashing
Browse files Browse the repository at this point in the history
Add polarfire flashing via USB-SD-MUX

Signed-off-by: Ville-Pekka Juntunen <[email protected]>
  • Loading branch information
vjuntunen committed Dec 1, 2023
1 parent 59ae0e3 commit 48764c7
Showing 1 changed file with 38 additions and 18 deletions.
56 changes: 38 additions & 18 deletions Jenkinsfiles/hw_test_set
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ performanceSuite = 'performance-tests/'
batSuite = 'bat-tests/'
deviceName = ''
usbHubSerial = ''
usbDrive = 'PSSD'
sdMuxUsbPort = ''
externalDrive = ''

pipeline {
agent { label "${params.label}" }
Expand All @@ -39,6 +40,8 @@ pipeline {
deviceName = 'NUC1'
} else if (params.device == "orin-nx"){
deviceName = 'OrinNX1'
} else if (params.device == "riscv"){
deviceName = 'Polarfire1'
}
} else if ("${params.label}" == "tc-agent03"){
if (params.device == "orin-agx"){
Expand All @@ -47,17 +50,28 @@ pipeline {
deviceName = 'NUC2'
} else if (params.device == "orin-nx"){
deviceName = 'OrinNX2'
} else if (params.device == "riscv"){
deviceName = 'Polarfire1'
}
}
echo "DEVICE: ${deviceName}"

// Set pipeline description
currentBuild.description = "${params.server} ${params.device} BuildID: ${params.buildID}"

// Read test devices configfile and set usbHub serial to use right device
def deviceData = readJSON file: "${configPath}"
usbHubSerial = "${deviceData['addresses']["${deviceName}"]['usbhub_serial']}"
println("USB HUB serial: ${usbHubSerial}")
// Read test devices configfile and set usbHub serial or sd-mux usb port to use right device
if ("${params.device}" == "riscv"){
externalDrive = 'sdmux'
def deviceData = readJSON file: "${configPath}"
sdMuxUsbPort = "${deviceData['addresses']["${deviceName}"]['usb_sd_mux_port']}"
println("SD-MUX USB port: ${sdMuxUsbPort}")

} else {
externalDrive = 'PSSD'
def deviceData = readJSON file: "${configPath}"
usbHubSerial = "${deviceData['addresses']["${deviceName}"]['usbhub_serial']}"
println("USB HUB serial: ${usbHubSerial}")
}

if ("${params.device}" == "orin-agx" || "${params.device}" == "orin-nx") {
// Read zipped image file path from buildID.json to flash usb drive for Orin device
Expand All @@ -68,47 +82,53 @@ pipeline {
}
}
}
stage('Change USB HUB host to PC') {
stage('Change host to PC') {
steps {
script{
sh "./BrainStem_dev_kit/bin/AcronameHubCLI -u 0 -s ${usbHubSerial}"

if ("${params.device}" == "riscv"){
sh "sudo usbsdmux ${sdMuxUsbPort} host"
} else {
sh "./BrainStem_dev_kit/bin/AcronameHubCLI -u 0 -s ${usbHubSerial}"
}
// wait that USB drive is mounted
sh 'sleep 10'
def output = sh (
// Check for usb drive that is connected to target test device
script: "lsblk -o model,name |grep ${usbDrive}",
script: "lsblk -o model,name |grep ${externalDrive}",
returnStdout: true
).trim()
).trim()
def list = output.split(' ')

// Take last element which is the target USB device
USBDEVICE = list[-1]
println("USB device: ${USBDEVICE}")

}
}
}
stage('Write OS image to USB disk') {
stage('Write OS image') {
steps {
script{
println("${params.image}")
println("${params.device}")
if ("${params.device}" == "orin-nx" || "${params.device}" == "orin-agx") {
// unzip zipped image, remove .zst ending from path and use that for flashing usb drive. Remove unzipped image after flashing.
sh "sudo zstd -d ${zipImagePath}"
unzippedPath = zipImagePath.minus(".zst")
sh "sudo dd if=${unzippedPath} of=/dev/${USBDEVICE} bs=1M status=progress conv=fsync"
sh "sudo rm -rf ${unzippedPath}"
// Use zstd to decompress the image and write directly to the USB drive.
sh "sudo zstd -d ${zipImagePath} -o /dev/${USBDEVICE}"
sh "sync"
} else {
sh "sudo dd if=${params.image} of=/dev/${USBDEVICE} bs=1M status=progress conv=fsync"
}
}
}
}
stage('Change USB HUB host back to test device') {
stage('Change host back to test device') {
steps {
script{
sh "./BrainStem_dev_kit/bin/AcronameHubCLI -u 1 -s ${usbHubSerial}"
if ("${params.device}" == "riscv"){
sh "sudo usbsdmux ${sdMuxUsbPort} dut"
} else {
sh "./BrainStem_dev_kit/bin/AcronameHubCLI -u 1 -s ${usbHubSerial}"
}
}
}
}
Expand Down

0 comments on commit 48764c7

Please sign in to comment.