Cyclone V Board handsoff script
Subsystems (3)
PATCH 1/1 Cyclone V Board handsoff script
Since turning from old build flow.
New Altera SoCFPGA requires converting handsoff
conversion via the python script. This is from
official provided, and now sync to U-Boot
--- .../cv_bsp_generator/cv_bsp_generator.py | 100 +++ arch/arm/mach-socfpga/cv_bsp_generator/doc.py | 243 ++++++++ .../arm/mach-socfpga/cv_bsp_generator/emif.py | 424 +++++++++++++ arch/arm/mach-socfpga/cv_bsp_generator/hps.py | 571 ++++++++++++++++++ .../mach-socfpga/cv_bsp_generator/iocsr.py | 203 +++++++ .../mach-socfpga/cv_bsp_generator/model.py | 114 ++++ .../mach-socfpga/cv_bsp_generator/renderer.py | 196 ++++++ .../mach-socfpga/cv_bsp_generator/streamer.py | 102 ++++ .../mach-socfpga/cv_bsp_generator/xmlgrok.py | 32 + 9 files changed, 1985 insertions(+) create mode 100755 arch/arm/mach-socfpga/cv_bsp_generator/cv_bsp_generator.py create mode 100755 arch/arm/mach-socfpga/cv_bsp_generator/doc.py create mode 100755 arch/arm/mach-socfpga/cv_bsp_generator/emif.py create mode 100755 arch/arm/mach-socfpga/cv_bsp_generator/hps.py create mode 100755 arch/arm/mach-socfpga/cv_bsp_generator/iocsr.py create mode 100755 arch/arm/mach-socfpga/cv_bsp_generator/model.py create mode 100755 arch/arm/mach-socfpga/cv_bsp_generator/renderer.py create mode 100755 arch/arm/mach-socfpga/cv_bsp_generator/streamer.py create mode 100755 arch/arm/mach-socfpga/cv_bsp_generator/xmlgrok.py
arch/arm/mach-socfpga/cv_bsp_generator/cv_bsp_generator.py new file +100 -0
@@ -0,0 +1,100 @@ +#! /usr/bin/env python +# SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause +""" +Bsp preloader header file generator + +Process the handoff files from Quartus and convert them to headers +usable by U-Boot. Includes the qts filter.sh capability to generate +correct format for headers to be used for mainline Uboot on FPGA, +namely Cyclone V & Arria V. + +Copyright (C) 2022 Intel Corporation <www.intel.com> + +Author: Lee, Kah Jing <[email protected]> +""" +import glob +import optparse +import os +import shutil +import emif +import hps +import iocsr +import renderer +import model +import collections +import sys + +def printUsage(): + """ usage string """ + print ("Usage:\n\t%s\n" % ("sys.argv[0], --input_dir=<path to iswinfo directory> --output_dir=<path store output files>")) + exit(1) + +def verifyInputDir(dir): + """ check if the input directory exists """ + if not os.path.isdir(dir): + print ("There is no such directory '%s'!\n" % (dir)) + exit(1) + +def verifyOutputDir(dir): + """ check if the output directory exists """ + if not os.path.isdir(dir): + os.makedirs(dir) + +if __name__ == '__main__': + # Do some rudimentary command line processing until it is proven we need something + # heavier, such as argparse (preferred, but 2.7+ only) or optparse + + inputDir = '.' + outputDir = '.' + + progVersion = '%prog 1.0' + progDesc = 'Generate board-specific files for the preloader' + optParser = optparse.OptionParser(version=progVersion, description=progDesc) + optParser.add_option('-i', '--input-dir', action='store', type='string', dest='inputDir', default='.', + help='input-dir is usually the iswinfo directory') + optParser.add_option('-o', '--output-dir', action='store', type='string', dest='outputDir', default='.', + help='output-dir is usually the directory containing the preloader source') + + (options, args) = optParser.parse_args() + + for arg in args: + print ("***WARNING: I don't understand '%s', so I am ignoring it\n" % (arg)) + + inputDir = options.inputDir + verifyInputDir(inputDir) + outputDir = options.outputDir + + verifyOutputDir(outputDir) + + emif = emif.EMIFGrokker(inputDir, outputDir, 'emif.xml') + hps = hps.HPSGrokker(inputDir, outputDir) + + pllConfigH = outputDir + "/" + "pll_config.h" + print ("Generating file: " + pllConfigH) + hpsModel = model.hps.create(inputDir + "/" + "hps.xml") + emifModel = model.emif.create(inputDir +"/" + "emif.xml") + + content=str(renderer.pll_config_h(hpsModel, emifModel)) + f = open(pllConfigH, "w") + f.write(content) + f.close() + + # For all the .hiof files, make a iocsr_config.[h|c] + # Only support single hiof file currently + hiof_list = glob.glob(inputDir + os.sep + "*.hiof") + if len(hiof_list) < 1: + print ("***Error: No .hiof files found in input!") + + elif len(hiof_list) > 1: + print ("***Error: We don't handle more than one .hiof file yet") + print (" Only the last .hiof file in the list will be converted") + print (" hiof files found:") + for f in hiof_list: + print (" " + f) + + for hiof_file_path in hiof_list: + hiof_file = os.path.basename(hiof_file_path) + # Avoid IOCSRGrokker having to parse hps.xml to determine + # device family for output file name, instead we'll just + # get it from HPSGrokker + iocsr = iocsr.IOCSRGrokker(hps.getDeviceFamily(), inputDir, outputDir, hiof_file)
arch/arm/mach-socfpga/cv_bsp_generator/doc.py new file +243 -0
243 lines not on this page · raw message
arch/arm/mach-socfpga/cv_bsp_generator/emif.py new file +424 -0
424 lines not on this page · raw message
arch/arm/mach-socfpga/cv_bsp_generator/hps.py new file +571 -0
571 lines not on this page · raw message
arch/arm/mach-socfpga/cv_bsp_generator/iocsr.py new file +203 -0
203 lines not on this page · raw message
arch/arm/mach-socfpga/cv_bsp_generator/model.py new file +114 -0
114 lines not on this page · raw message
arch/arm/mach-socfpga/cv_bsp_generator/renderer.py new file +196 -0
196 lines not on this page · raw message
arch/arm/mach-socfpga/cv_bsp_generator/streamer.py new file +102 -0
102 lines not on this page · raw message
arch/arm/mach-socfpga/cv_bsp_generator/xmlgrok.py new file +32 -0
@@ -0,0 +1,32 @@ +# SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause +""" +XML node parser + +Copyright (C) 2022 Intel Corporation <www.intel.com> + +Author: Lee, Kah Jing <[email protected]> +""" +import xml.dom + +def isElementNode(XMLNode): + """ check if the node is element node """ + return XMLNode.nodeType == xml.dom.Node.ELEMENT_NODE + +def firstElementChild(XMLNode): + """ Calling firstChild on an Node of type Element often (always?) + returns a Node of Text type. How annoying! Return the first Element + child + """ + child = XMLNode.firstChild + while child != None and not isElementNode(child): + child = nextElementSibling(child) + return child + +def nextElementSibling(XMLNode): + """ nextElementSibling will return the next sibling of XMLNode that is + an Element Node Type + """ + sib = XMLNode.nextSibling + while sib != None and not isElementNode(sib): + sib = sib.nextSibling + return sib
Signature · 1 line
2.25.1
Quoted 6 lines · Brian Sune
Since turning from old build flow.
New Altera SoCFPGA requires converting handsoff conversion via the python script. This is from official provided, and now sync to U-BootSigned-off-by Brian Sune <[email protected]>
Quoted 11 lines
--- .../cv_bsp_generator/cv_bsp_generator.py | 100 +++ arch/arm/mach-socfpga/cv_bsp_generator/doc.py | 243 ++++++++ .../arm/mach-socfpga/cv_bsp_generator/emif.py | 424 +++++++++++++ arch/arm/mach-socfpga/cv_bsp_generator/hps.py | 571 ++++++++++++++++++ .../mach-socfpga/cv_bsp_generator/iocsr.py | 203 +++++++ .../mach-socfpga/cv_bsp_generator/model.py | 114 ++++ .../mach-socfpga/cv_bsp_generator/renderer.py | 196 ++++++ .../mach-socfpga/cv_bsp_generator/streamer.py | 102 ++++ .../mach-socfpga/cv_bsp_generator/xmlgrok.py | 32 + 9 files changed, 1985 insertions(+)
I'm not sure this should live in U-Boot. And if it really needs to be hosted by U-Boot and not hosted/maintained by altera somewhere, that this is the right place in the tree for it. I assume you run this tool on the output of some other tool?
Signature · 1 line
Tom
Quoted 4 lines
I'm not sure this should live in U-Boot. And if it really needs to be hosted by U-Boot and not hosted/maintained by altera somewhere, that this is the right place in the tree for it. I assume you run this tool on the output of some other tool?
No, this is a build script that is a must and also required on every clean build.
Those board c files are only good for very one specific board but not those listed.
And I supposed these scripts will also call on MakeFile after several patches.
These python scripts are used for handoff SoCFPGA project to U-Boot board folder C files. w/o these scripts the board files are messed up and cannot boot accordingly. This is why it exist from official after the newer build flow.
Brian
Quoted 2 lines
No, this is a build script that is a must and also required on every clean build.
Let me elaborate a bit more.
According to the current U-Boot folder:
board/altera/cyclone5-socdk/qts
board/altera/arria5-socdk
board/altera/arria10-socdk
All these board folder files are not sure and high change to be stall. As the deconfig boards are not only official Altera board. As such [1] is a prerequisite to build U-Boot.
So unless there are handoff changes until the EOL of 2030. These scripts are highly required on U-Boot, unless U-Boot plan to remove Altera SoCFPGA from the ARM support list.
Brian
Quoted 13 lines · Sune Brian
Quoted 2 lines
No, this is a build script that is a must and also required on every clean build.
Let me elaborate a bit more.
According to the current U-Boot folder:
board/altera/cyclone5-socdk/qts
board/altera/arria5-socdk
board/altera/arria10-socdkAll these board folder files are not sure and high change to be stall. As the deconfig boards are not only official Altera board. As such [1] is a prerequisite to build U-Boot.
Quoted 7 lines
So unless there are handoff changes until the EOL of 2030. These scripts are highly required on U-Boot, unless U-Boot plan to remove Altera SoCFPGA from the ARM support list.
Brian
That's interesting. But that also does mean that someone needs to work better with upstream about integration here as no, that's not where that kind of tooling should live. At bare minimum it should be in tools/something/ and have it's own requirements.txt file too for whatever python modules it requires.
Signature · 1 line
Tom
Quoted 5 lines
That's interesting. But that also does mean that someone needs to work better with upstream about integration here as no, that's not where that kind of tooling should live. At bare minimum it should be in
tools/something/and have it's own requirements.txt file too for whatever python modules it requires.
Do you mean I should move it to tool folder?
Brian
Quoted 3 lines
kind of tooling should live. At bare minimum it should be in
tools/something/and have it's own requirements.txt file too for whatever python modules it requires.
I just pull from official and this is the location where Altera puts. If you think it should belongs to a better place please do make suggestions how to do so.
Brian
Quoted 7 lines · Sune Brian
Quoted 5 lines
That's interesting. But that also does mean that someone needs to work better with upstream about integration here as no, that's not where that kind of tooling should live. At bare minimum it should be in
tools/something/and have it's own requirements.txt file too for whatever python modules it requires.Do you mean I should move it to tool folder?
Yes, as a starting point this should live under tools/something/ and if there's some way to add Makefile rules to automate xml -> c that would probably help other users. But that's just a nice to have thing. Thanks!
Signature · 1 line
Tom
Quoted 2 lines
there's some way to add
Makefilerules to automate xml -> c that would probably help other users. But that's just a nice to have thing. Thanks!
For the Makefike I need some time to understand the flow and how to add it. Just push the backbone to the trunk first. At least the user can run it more easily.
Brian