FixedWire Posted November 4, 2021 Report Share Posted November 4, 2021 Hi everyone, After searching both forums I've not been able to source a way to easily create either file format. There are examples reading these files but not writing them. Segger simply gave the Python script below. Unfortunately we can't simply just install Python as this is in a regulated environment. So we're hoping for a native LabVIEW solution. Surely someone has done this before. It gets a bit complicated if we need to roll our own down to the bit level & then having to do a full validation on it. I'd really rather not go there. Thanks in advance! python script (the "intelhex" does the heavy lifting) from intelhex import IntelHex h = IntelHex(None) h[0x1000] = 0x12 h[0x1001] = 0x34 h[0x1002] = 0x56 h[0x1003] = 0x78 h.write_hex_file('patch.hex') Quote Link to comment
Neil Pate Posted November 4, 2021 Report Share Posted November 4, 2021 I have done something like this years ago. I will see if I can dust off what I have. My memory could be totally faulty though! Quote Link to comment
Neil Pate Posted November 4, 2021 Report Share Posted November 4, 2021 Sorry @FixedWire, I took a look at my old code and indeed I have LabVIEW code to read a hex file, not to generate it. Quote Link to comment
FixedWire Posted November 4, 2021 Author Report Share Posted November 4, 2021 Appreciate that Neil! NI Support didn't find anything right away either. Quote Link to comment
Rolf Kalbermatter Posted November 5, 2021 Report Share Posted November 5, 2021 Typically, writing such a beast isn't exactly rocket science. But validating it is, and whoever could send you some code doing this, it would be: - Just implementing as much as they needed at that point and everything else might be not there or wrong - Almost certainly not validated: "Look mam it works, without hands!" "Great son, now don't touch it!" So the major part of the work would still be on you unless someone had a real product that they did some good validation on, and will cost considerable money. Writing your own will be unsexy: Who the heck is still writing assembly binary files anymore? 😀, but it is most likely unavoidable in this case and the real work is in the validation that you mention and that will have to be done anyhow if your product is in such a regulated industry. Quote Link to comment
sam Posted November 5, 2021 Report Share Posted November 5, 2021 Couple of years ago I was working with SREC files, but I only needed to import them. Initially I used LabVIEW but switch to C# as it was more suited. This is only the import part, maybe it can get you started (reverse the process?, idk). as Rolf said, my concern was only import and my project requirement and then switched to C# anyways, the only thing I tested was making sure both my LabVIEW and C# were doing the import the same way. Parse SREC File.vi 1 Quote Link to comment
FixedWire Posted November 5, 2021 Author Report Share Posted November 5, 2021 Thanks Rolf, Sam. This certainly helps and the vi gives a lot of detailed insight. The validation is the rabbit hole. If I use the simple InteHex Python code, as there a way to "lock down" a Python module so the Python dev environment isn't available for someone to access? Quote Link to comment
hooovahh Posted November 8, 2021 Report Share Posted November 8, 2021 Yes I too am only familiar with reading these file types but not writing. NI has the ECU Measurement and Calibration Toolkit which is a CAN toolkit for performing XCP and CCP functions. One of which is flashing new software to an ECU over CAN. In there is the start of some code that reads SREC and HEX files. Some of the file types were had poor performance and I made an attempt at improving them. This code can be found in the CAN File IO package here. But I admit that is a whole lot of code to install for some simple file reading stuff so I've attached the important bits here. This appears to support S0 through S9 types, and some kind of HEX files that start with a ":". Looking at the code I still see some room for improvement. Hooovahh SREC and HEX.zip Quote Link to comment
ShaunR Posted November 8, 2021 Report Share Posted November 8, 2021 Many moons ago I wrote a cloner for embedded devices. It basically dumped a device firmware image to an S-Record file which was then used to upload to other devices on the production line. Like Rolf said. It did enough to do the task for those devices and took a couple of hours to write the basic functionality - S-Records aren't a difficult format. It just started at an address and byte-copied chunks so only S3 was required for that (and the S0/9). I think you'll find that most people either knock up a quick utility like that or invoke the programmer utility. 10 hours ago, hooovahh said: some kind of HEX files that start with a ":". That's the Intel Hex format. Quote Link to comment
FixedWire Posted November 9, 2021 Author Report Share Posted November 9, 2021 We ended up finding a relatively simple solution using command line calls from http://srecord.sourceforge.net/ At least there is source code if it is ever needed and it's compiled unlike the Python approach. For what we need the risks can be mitigated. Thanks everyone. It's just incredible to have such resources available. Kudos to all. Quote Link to comment
Rolf Kalbermatter Posted November 12, 2021 Report Share Posted November 12, 2021 On 11/9/2021 at 8:42 PM, FixedWire said: We ended up finding a relatively simple solution using command line calls from http://srecord.sourceforge.net/ At least there is source code if it is ever needed and it's compiled unlike the Python approach. For what we need the risks can be mitigated. Thanks everyone. It's just incredible to have such resources available. Kudos to all. They also support a shared library interface! Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.