In the silabs IDE Use tools / upload memory to file, and save it as hex
convert it to binary (ex. the code below)
convert from binary to intel-hex
sudo apt-get install srecord
srec_cat file.bin -Binary -Output file.hex -Intel
use silabs ide Debug/dowload object file to write the file
====FROM HEX TO BINARY====
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc,char** argv){
if (argc<3){
cout<<"Usage "<<argv[0]<<" infile.hex.txt outfile.bin"<<endl;
return 0;
}
fstream in(argv[1], ios::in);
fstream out(argv[2], ios::out | ios::binary);
int h;
while(in){
in>>std::hex>>h;
unsigned char c=h;
if (in){
out.write((char*)(&c),1);
}
}
out.close();
}
convert it to binary (ex. the code below)
convert from binary to intel-hex
sudo apt-get install srecord
srec_cat file.bin -Binary -Output file.hex -Intel
use silabs ide Debug/dowload object file to write the file
====FROM HEX TO BINARY====
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc,char** argv){
if (argc<3){
cout<<"Usage "<<argv[0]<<" infile.hex.txt outfile.bin"<<endl;
return 0;
}
fstream in(argv[1], ios::in);
fstream out(argv[2], ios::out | ios::binary);
int h;
while(in){
in>>std::hex>>h;
unsigned char c=h;
if (in){
out.write((char*)(&c),1);
}
}
out.close();
}
No comments:
Post a Comment