DATA_DIR override with environment variable (#333)
This commit is contained in:
parent
1bdb117b74
commit
cd8a143164
|
|
@ -92,6 +92,7 @@ set(OPENFPGALOADER_SOURCE
|
||||||
src/anlogicBitParser.cpp
|
src/anlogicBitParser.cpp
|
||||||
src/anlogicCable.cpp
|
src/anlogicCable.cpp
|
||||||
src/ch552_jtag.cpp
|
src/ch552_jtag.cpp
|
||||||
|
src/common.cpp
|
||||||
src/dfu.cpp
|
src/dfu.cpp
|
||||||
src/dfuFileParser.cpp
|
src/dfuFileParser.cpp
|
||||||
src/dirtyJtag.cpp
|
src/dirtyJtag.cpp
|
||||||
|
|
@ -140,6 +141,7 @@ set(OPENFPGALOADER_HEADERS
|
||||||
src/anlogicBitParser.hpp
|
src/anlogicBitParser.hpp
|
||||||
src/anlogicCable.hpp
|
src/anlogicCable.hpp
|
||||||
src/ch552_jtag.hpp
|
src/ch552_jtag.hpp
|
||||||
|
src/common.hpp
|
||||||
src/cxxopts.hpp
|
src/cxxopts.hpp
|
||||||
src/dfu.hpp
|
src/dfu.hpp
|
||||||
src/dfuFileParser.hpp
|
src/dfuFileParser.hpp
|
||||||
|
|
|
||||||
18
README.md
18
README.md
|
|
@ -124,3 +124,21 @@ for any corresponding short options.
|
||||||
|
|
||||||
Report bugs to <gwenhael.goavec-merou@trabucayre.com>.
|
Report bugs to <gwenhael.goavec-merou@trabucayre.com>.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
By default **spiOverJtag** are search into `${CMAKE_INSTALL_FULL_DATAROOTDIR}`
|
||||||
|
(*/usr/local/share/* by default). It's possible to change this behaviour by
|
||||||
|
using an environment variable:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export OPENFPGALOADER_SOJ_DIR=/somewhere
|
||||||
|
openFPGALoader xxxx
|
||||||
|
```
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
```
|
||||||
|
OPENFPGALOADER_SOJ_DIR=/somewhere openFPGALoader xxxx
|
||||||
|
```
|
||||||
|
|
||||||
|
`OPENFPGALOADER_SOJ_DIR` must point to directory containing **spiOverJtag**
|
||||||
|
bitstreams.
|
||||||
|
|
|
||||||
|
|
@ -82,3 +82,20 @@ Writing to an arbitrary address in flash memory
|
||||||
|
|
||||||
With FPGA using an external SPI flash (*xilinx*, *lattice ECP5/nexus/ice40*, *anlogic*, *efinix*) option ``-o`` allows
|
With FPGA using an external SPI flash (*xilinx*, *lattice ECP5/nexus/ice40*, *anlogic*, *efinix*) option ``-o`` allows
|
||||||
one to write raw binary file to an arbitrary adress in FLASH.
|
one to write raw binary file to an arbitrary adress in FLASH.
|
||||||
|
|
||||||
|
Using an alternative directory for *spiOverJtag*
|
||||||
|
================================================
|
||||||
|
|
||||||
|
By setting ``OPENFPGALOADER_SOJ_DIR`` it's possible to override default
|
||||||
|
*spiOverJtag* bitstreams directory:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
export OPENFPGALOADER_SOJ_DIR=/somewhere
|
||||||
|
openFPGALoader xxxx
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
OPENFPGALOADER_SOJ_DIR=/somewhere openFPGALoader xxxx
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "common.hpp"
|
||||||
#include "jtag.hpp"
|
#include "jtag.hpp"
|
||||||
#include "device.hpp"
|
#include "device.hpp"
|
||||||
#include "epcq.hpp"
|
#include "epcq.hpp"
|
||||||
|
|
@ -181,12 +182,11 @@ bool Altera::load_bridge()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// DATA_DIR is defined at compile time.
|
bitname = get_shell_env_var("OPENFPGALOADER_SOJ_DIR", DATA_DIR "/openFPGALoader");
|
||||||
bitname = DATA_DIR "/openFPGALoader/spiOverJtag_";
|
|
||||||
#ifdef HAS_ZLIB
|
#ifdef HAS_ZLIB
|
||||||
bitname += _device_package + ".rbf.gz";
|
bitname += "/spiOverJtag_" + _device_package + ".rbf.gz";
|
||||||
#else
|
#else
|
||||||
bitname += _device_package + ".rbf";
|
bitname += "/spiOverJtag_" + _device_package + ".rbf";
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2023 Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "common.hpp"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief return shell environment variable value
|
||||||
|
* \param[in] key: variable name
|
||||||
|
* \return variable value or ""
|
||||||
|
*/
|
||||||
|
const std::string get_shell_env_var(const char* key,
|
||||||
|
const char *def_val) noexcept {
|
||||||
|
const char* ret = std::getenv(key);
|
||||||
|
return std::string(ret ? ret : def_val);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2023 Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SRC_COMMON_HPP_
|
||||||
|
#define SRC_COMMON_HPP_
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief return shell environment variable value
|
||||||
|
* \param[in] key: variable name
|
||||||
|
* \param[in] def_val: value to return when not found
|
||||||
|
* \return variable value or def_val
|
||||||
|
*/
|
||||||
|
const std::string get_shell_env_var(const char* key,
|
||||||
|
const char *def_val="") noexcept;
|
||||||
|
|
||||||
|
#endif // SRC_COMMON_HPP_
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
#include "jtag.hpp"
|
#include "jtag.hpp"
|
||||||
#include "bitparser.hpp"
|
#include "bitparser.hpp"
|
||||||
|
#include "common.hpp"
|
||||||
#include "configBitstreamParser.hpp"
|
#include "configBitstreamParser.hpp"
|
||||||
#include "jedParser.hpp"
|
#include "jedParser.hpp"
|
||||||
#include "mcsParser.hpp"
|
#include "mcsParser.hpp"
|
||||||
|
|
@ -468,9 +469,8 @@ bool Xilinx::load_bridge()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// DATA_DIR is defined at compile time.
|
bitname = get_shell_env_var("OPENFPGALOADER_SOJ_DIR", DATA_DIR "/openFPGALoader");
|
||||||
bitname = DATA_DIR "/openFPGALoader/spiOverJtag_";
|
bitname += "/spiOverJtag_" + _device_package + ".bit.gz";
|
||||||
bitname += _device_package + ".bit.gz";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined (_WIN64) || defined (_WIN32)
|
#if defined (_WIN64) || defined (_WIN32)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue