I have STM32F404 board and I am trying to flash it. I am following this tutorial.
In the project Makefile
$(PROJ_NAME).elf: $(SRCS)
$(CC) $(CFLAGS) $^ -o $#
$(OBJCOPY) -O ihex $(PROJ_NAME).elf $(PROJ_NAME).hex
$(OBJCOPY) -O binary $(PROJ_NAME).elf $(PROJ_NAME).bin
burn: proj
$(STLINK)/st-flash write $(PROJ_NAME).bin 0x8000000
The bin file is generated using OBJCOPYand then flashed using the Make target burn
My questions :
Question 1: What does OBJCOPY=arm-none-eabi-objcopy in this case. I opened the man but I didn't fully undrestand can anyone explain it simply ?
Question 2: Flashing the bin file gives the expected result (Leds blinking) However the leds are not blinking by flashing the elf file $(STLINK)/st-flash write $(PROJ_NAME).elf 0x8000000 so why ?
Question 1: What does OBJCOPY=arm-none-eabi-objcopy in this case. I opened the man but I didn't fully undrestand can anyone explain it simply ?
It assigns value arm-none-eabi-objcopy to make variable OBJCOPY.
When make executes this command:
$(OBJCOPY) -O binary $(PROJ_NAME).elf $(PROJ_NAME).bin
the actual command that runs is
arm-none-eabi-objcopy -O binary tim_time_base.elf tim_time_base.bin
Question 2: Flashing the bin file gives the expected result (Leds blinking) However the leds are not blinking by flashing the elf file $(STLINK)/st-flash write $(PROJ_NAME).elf 0x8000000 so why?
The tim_time_base.elf is an ELF file -- it has metadata associated with it. Run arm-none-eabi-readelf -h tim_time_base.elf to see what some of this metadata are.
But when you processor jumps to location 0x8000000 after reset, it is expecting to find executable instructions, not metadata. When it finds "garbage" it doesn't understand, it probably just halts. It certainly doesn't find instructions to blink the lights.
In case someone wants to use the DFU ("Do a Firmware Upgrade") function, this tutorial teaches how to use the binary file to be loaded via USB, when the STM32 is operating with USB Host (or maybe OTG):
STM32 USB training - 11.3 USB MSC DFU host labs
This tutorial is part of a series of videos that are highly recommended for the programmer to watch, to understand a little better how the STM32 USB ports work and use (videos provided by the STM32 manufacturer itself, I recommend that the programmer watch all the videos on this channel):
MOOC - STM32 USB training
Notes: The example code from the STM32 tutorials are available in the descriptions of the videos themselves.
The binary file (*.bin) can be obtained with the help of the command that the colleague above explained (Employed Russian), and it (command) can also be adapted to produce a file containing the comparison value for CRC usage, as can be seen some details in these following posts:
Hands-on: CRC Checksum Generation
Srec_cat could be used to generate CRC checksum and put it into HEX
file. To simplify the process, please put srec_cat.exe into the root
of project folder.
Some tips and solutions about this CRC usage (Windows/Linux)
Unfortunately the amount of code is too big to post here directly, but I leave the code related to the other answer below:
arm-none-eabi-objcopy -O ihex "${BuildArtifactFileBaseName}.elf"
"${BuildArtifactFileBaseName}.hex" && ..\checksum.bat
${BuildArtifactFileBaseName}.hex
Contents of the checksum.bat file:
#!/bin/bash
# Windows [Dos comment: REM]:
#..\srec_cat.exe %1 -Intel -fill 0xFF 0x08000000 0x080FFFFC -STM32 0x080FFFFC -o ROM.hex -Intel
# Linux [Linux comment: #]:
srec_cat $1 -Intel -fill 0xFF 0x08000000 0x080FFFFC -STM32 0x080FFFFC -o ROM.hex -Intel
Note: In this case, the file to be written is ROM.hex (you will need to configure the STM32CubeIDE to be able to do this operation, the IDE uses the *.elf file, see how to do it in the tips above)
This other tutorial deals with using the file with *.DFU extension:
DFU - DfuSe
The key benefits of the DFU Boatloader are: No specific tools such us
JTAG, ST-LINK or USB-to-UART cable are needed. The ability to program
an "empty" STM32 device in a newly-assembled board via USB. And easy
upgrade the STM32 firmware during development or pre-production.
This need to use a HEX file facilitates the operation of the implementation of the ROM.hex file generated with the CRC value, being practically a continuity:
You must generate a .DFU file from an .HEX or .S19 file, for do this
use the DFU File Manager.
But it seems that using the *.DFU file is not as standalone as using the *.BIN file, so I found this other code that converts the HEX file (generated with CRC) to the *.BIN file, which can be used with a USB stick, as per the tutorial cited at the beginning of this answer (11.3 USB MSC DFU host):
objcopy --input-target=ihex --output-target=binary code00.hex code00.bin
Source
It sounds a little confusing, but we have these steps:
1- The STM32CubeIDE generates the *.elf file.
2- After compilation, the *.elf file is converted to *.hex.
3- CRC value is added in *.hex file via srec_cat application.
4- Now the *.hex file is converted to *.bin.
5- The BIN file is then stored on a USB flash drive.
6- STM32 updates firmware using USB flash drive file.
To use the *.BIN file it is necessary that the STM32 is already programmed to load the BIN file. If it is not programmed (the STM32 is empty, virgin or the program was not made to load the BIN file), it will be necessary to use St-Link or another programmer, or perhaps making use of the DFU method described in the tutorial above (DFU - DfuSe).
Related
I want to use Tesseract to recognize code. It is said on their website that I can disable dictionaries by setting both of the configuration variables load_system_dawg and load_freq_dawg to false.
However I haven't been able to do it correctly.
$ tesseract img.jpg output.txt --oem 0 -c load_system_dawg=0 load_freq_dawg=0
read_params_file: Can't open load_freq_dawg=0
Error: Tesseract (legacy) engine requested, but components are not present in /usr/share/tesseract-ocr/4.00/tessdata/eng.traineddata!!
Failed loading language 'eng'
Tesseract couldn't load any languages!
Could not initialize tesseract.
Any ideas on best ways to handle it?
First of all, get eng.traineddata with the legacy engine or other OCR engine value (OEM).
Next, read the output of tesseract --help-extra carefully:
-c VAR=VALUE Set value for config variables.
Multiple -c arguments are allowed.
I am very new to coding so I'm not really sure how to approach this. I wanted to look at some data that we got and sequence them using Bismark. I already used Trim Galore to pare the reads, now I wanted to get the data into Bismark. However, I'm not exactly sure how to approach this. In the documentation it said that it required Perl to run so I downloaded Perl along with the Bismark zip file from github. I also downloaded the bowtie2 zip file and extracted both the zip files into the same directory. I then opened up the Perl command prompt and set the directory to one with my extracted folders.
I put this line in:
> \bismark\bismark_genome_preparation --path_to_bowtie ^
C:\Users\sevro\Documents\Lab_Code\bowtie2-master --verbose ^
C:\Users\sevro\Documents\Lab_Code\genome
The system cannot find the path specified.
I also tried this after changing the directory to the Bismark folder:
> perl bismark
Failed to execute Bowtie 2 porperly (return code of 'bowtie2 --version' was 256).
Please install Bowtie 2 or HISAT2 first and make sure it is in the PATH,
or specify the path to the Bowtie 2 with --path_to_bowtie2 /path/to/bowtie2,
or --path_to_hisat2 /path/to/hisat2
I tried a few other things but all in all I am a bit confused on how exactly to approach this. Things I have downloaded right now:
Bismark zip file- https://github.com/FelixKrueger/Bismark
Bowtie2 zip file- https://github.com/BenLangmead/bowtie2
A genome assembly in .fa format
The data that I want to analyze in fasta format
Any insight would be helpful.
I think Bismark and bowtie2 only supports Linux and macOS natively. If you want to use bismark on Windows you can try install it via a *nix emulation systems like Cygwin, MSYS2, or simply use WSL. I tested this on Windows 11 with WSL with Ubuntu 20.04:
Downloaded bowtie2-2.4.4-linux-x86_64.zip and extracted to ~/bowtie2/bowtie2-2.4.4-linux-x86_64 folder.
Downloaded Bismark-0.23.1.zip and extracted to ~/bismark/Bismark-0.23.1/
Tested installation:
$ perl --version
This is perl 5, version 30, subversion 0 (v5.30.0) built for x86_64-linux-gnu-thread-multi (with 50 registered patches, see perl -V for more detail)
$ perl bismark --path_to_bowtie2 ../../bowtie2/bowtie2-2.4.4-linux-x86_64/Bowtie 2 seems to be working fine (tested command '../../bowtie2/bowtie2-2.4.4-linux-x86_64/bowtie2 --version' [2.4.4])
Output format is BAM (default)
Did not find Samtools on the system. Alignments will be compressed with GZIP instead (.sam.gz)
Genome folder was not specified!
DESCRIPTION
The following is a brief description of command line options and arguments to control the Bismark
bisulfite mapper and methylation caller. Bismark takes in FastA or FastQ files and aligns the
reads to a specified bisulfite genome. Sequence reads are transformed into a bisulfite converted forward strand
version (C->T conversion) or into a bisulfite treated reverse strand (G->A conversion of the forward strand).
Each of these reads are then aligned to bisulfite treated forward strand index of a reference genome
(C->T converted) and a bisulfite treated reverse strand index of the genome (G->A conversion of the
forward strand, by doing this alignments will produce the same positions). These 4 instances of Bowtie 2 or HISAT2
are run in parallel. The sequence file(s) are then read in again sequence by sequence to pull out the original
sequence from the genome and determine if there were any protected C's present or not.
The final output of Bismark is in BAM/SAM format by default, described in more detail below.
USAGE: bismark [options] <genome_folder> {-1 <mates1> -2 <mates2> | <singles>}
[...]
I need to strictly bind every core file generated by system to certain bin version of crashed application. I can specify core-name pattern in sysctl.conf:kernel.core_pattern, but there is no way to put bin version here.
How can I put the version of crashed program into core file (revision number) or any other way to determine version of crashed bin?
I'm using qmake VERSION variable in .pro file, which contains revision number from SVN. Its available by QCoreApplication::applicationVersion(), in my every bin by flag --version.
Assuming your app can get far enough to print out its version number without a core dump, you can write a small program (python would probably be easiest) that is invoked by a core dump. The program would read stdin, dump it to a file, then rename the file based on the version number.
From man 5 core:
Piping core dumps to a program
Since kernel 2.6.19, Linux supports an alternate syntax for the
/proc/sys/kernel/core_pattern file. If the first character of this
file is a pipe symbol (|), then the remainder of the line is inter‐
preted as a program to be executed. Instead of being written to a disk
file, the core dump is given as standard input to the program. Note
the following points:
* The program must be specified using an absolute pathname (or a path‐
name relative to the root directory, /), and must immediately follow
the '|' character.
* The process created to run the program runs as user and group root.
* Command-line arguments can be supplied to the program (since Linux
2.6.24), delimited by white space (up to a total line length of 128
bytes).
* The command-line arguments can include any of the % specifiers
listed above. For example, to pass the PID of the process that is
being dumped, specify %p in an argument.
If you call your script /usr/local/bin/dumper, then
echo "| /usr/local/bin/dumper %E" > /proc/sys/kernel/core_pattern
The dumper should copy stdin to a file, then try to run the program named on its command line to extract a version number and use that to rename the file.
Something like this might work (I haven't tried it, so use at extreme risk:)
#!/usr/bin/python
import sys,os,subprocess
from subprocess import check_output
CORE_FNAME="/tmp/core"
with open(CORE_FNAME,"f") as f:
while buf=sys.stdin.read(10000):
f.write(buf)
pname=sys.argv[1].replace('!','/')
out=subprocess.check_output([pname, "--version"])
version=out.split('\n')[0].split()[-1]
os.rename(CORE_FNAME, CORE_FNAME+version)
The really big risk of doing this is recursive core dumps that may crash your system. Be sure to use ulimit to only allow core dumps from processes that can print out their own versions without core dumping.
It would be a good idea to change the script to re-run the program to get the version info only if it is the program you are expecting.
After I generate code with Simulink Coder choosing grt.tlc target Matlab gives me this adres as executable's adress. C:/PROGRA~1/MATLAB/R2013a\sys\lcc\bin\lcclnk -s -LC:/PROGRA~1/MATLAB/R2013a\sys\lcc\lib -o ../untitled.exe What does it mean? What am I supposed to do when I get a misterious adress like this?
Nothing "mysterious"
Your executable is at
../untitled.exe
meaning untitled.exe is present in one folder above the current working folder, probably the place where the simulink model resides
-o is used for output file name given to linker.
Recently updated my Wireshark on a server, and lost the ability to use -R and -w from the CLI. Since I'm tracing SIP and RTP calls, I need to use -R and not -f.
I found out using -V is very useful (shows the packet tree on screen) and then I can redirect the output to a file. Unfortunately I'm not able to open that file through Wireshark to view properly (contains too muh text to easily scroll through).
I tried using -x t add the hex dump (removed -V), but still that is not openable through Wireshark when copying the text file to my PC.
Any ideas how I can trace using -R (with or without -V), copy the file to my PC and still be able to read it through Wireshark? I don't have issues to convert the file to a readable format.. Just need anything to view the files and share them :)
Thanks all,
//M