OpenOCD read_bank command asks for more arguments - embedded

We are trying to read out portions of our STM32F0x microcontrollers with OpenOCD, which we also use to program them. However, the flash read_bank command doesn't work as documented. Whatever we input, the error is:
flash read_bank 0 test.bin: command requires more arguments
We invoke it for example by:
sudo openocd -f interface/stlink-v2.cfg -f target/stm32f0x_stlink.cfg -c "init" -c "reset init" -c "flash read_bank 0 test.bin" -c "exit"
Other flash operations work as expected, such as:
openocd -f interface/stlink-v2.cfg -f target/stm32f0x_stlink.cfg -c init -c "flash info 0" -c exit
or
openocd -f interface/stlink-v2.cfg -f target/stm32f0x_stlink.cfg -c init -c "flash banks" -c exit
The command flash read_bank seems to be very rarely used. This is at least, was my google search said. Does anybody have an idea on how to use this command?

The flash read_bank comannd requires 2 more arguments: Offset and length.
So on a STM32 MCU I you could use
flash read_bank 0 test.bin 0x8000000 0x4000
to read the first 16KB of the flash memory.
Remember there is a "help" command in OpenOCD, too.

Related

How to halt a target device with pyocd?

I try to halt a F746zg core with pyocd via ST-LinkV2. The ST-Link sees the core. But I'm not able to erase and reprogram it until it's halted. Does anyone know what the right command is to do that?
I tried:
pyocd reset -l -t 'stm32f746zg'
But I get:
W Invalid coresight component, cidr=0x0 [rom_table]
I had the problem that the system was not flashable from remote with following command:
pyocd flash -e sector -a 0x8000000 -t 'stm32f746zg' -O reset_type=hw -O connect_mode='under-reset' zephyr.elf
But the following procedure seems to work for me.
Halt the system
pyocd reset -l -t 'stm32f746zg' -O reset_type=hw -O connect_mode='under-reset'
Erase sector and flash
pyocd flash -e sector -a 0x8000000 -t 'stm32f746zg' zephyr.elf

Systems programming qemu: unknown keycodes `(unnamed)'

I am trying to run qemu with code that my teacher provided so that we are able to work on our assignment.
This is being run in Ubuntu 18.04
LIBPATH=/usr/lib/gcc/arm-none-eabi/6.3.1/
arm-none-eabi-as -mcpu=arm926ej-s -g ts.s -o ts.o
arm-none-eabi-gcc -c -mcpu=arm926ej-s -g t.c -o t.o
arm-none-eabi-ld -T t.ld ts.o t.o -o t.elf
arm-none-eabi-ld -T t.ld -L $LIBPATH ts.o t.o -o t.elf -lgcc #-lstr
arm-none-eabi-objcopy -O binary t.elf t.bin
rm *.o *.elf
echo ready to go?
read dummy
qemu-system-arm -M realview-pbx-a9 -m 128M -kernel t.bin \
-serial mon:stdio -serial /dev/pts/2 -serial /dev/pts/2 -serial /dev/pts/2
And the numbers in the last line `-serial /dev/pts/#' are from running ps in the terminal and grabbing the number. All of this is in an executable file, and when I run the file the qemu screen does display, but when I press enter again I recieve this error message
unknown keycodes `(unnamed)', please report to qemu-devel#nongnu.org
I cannot seem to find any clear answer on how to solve this problem. I have tried uninstalling and reinstalling qemu a couple of time.
QEMU's "unknown keycodes" message is about key handling in its graphics window, and means that the host keyboard mapping you're using has some odd setup that it doesn't entirely understand. Usually this means that a few keys won't work right in the graphics window, and you can ignore it unless you're actually having a problem with them. The whole keycode system was completely rewritten in a newer version of QEMU, and this message doesn't even exist any more.
If your test program isn't expecting to use the graphical screen, then you can definitely ignore the message (indeed you could turn off the graphics screen entirely with -display none).
The command line options to QEMU you're using for the serial port look really odd -- you seem to be trying to connect multiple serial ports to the same host tty, which I'm pretty sure won't work right. Unless you're actually using serial ports 1 through 3, just drop those and use the serial port 0 that is set up with "-serial mon:stdio".

How to make ffmpeg exit when Input is broken

I have written a bash script to keep a ffmpeg command up and running
#!/bin/bash
while :
do
echo `ffmpeg -re -i http://domain.com/index400.m3u8 -vcodec copy -acodec copy -f mpegts udp://127.0.0.1:10000?pkt_size=1316`
done
The problem is, sometimes the input is broken, yet ffmpeg does not exit when that happens so that it is restarted by the above script. Instead what happens is the same process is kept running eventhough it is not transferring any packet to the UDP address (output). And I need to manually go into the terminal and kill it (kill -9 #processID)
I need a way to make ffmpeg kill its own process whenever the input is broken.
Appreciate your help.

resize one video in 2 sizes in single command

When user uploads video then I make its 2 sizes. Earlier, I was doing this in two steps like following
First Size:
ffmpeg -i in.mp4 -filter:v "scale=iw*min(1170/iw\,300/ih):ih*min(1170/iw\,300/ih), pad=1170:300:(1170-iw*min(1170/iw\,300/ih))/2:(300-ih*min(1170/iw\,300/ih))/2" out.mp4
Second Size:
ffmpeg -i in.mp4 -filter:v "scale=iw*min(365/iw\,172/ih):ih*min(365/iw\,172/ih), pad=365:172:(365-iw*min(365/iw\,172/ih))/2:(172-ih*min(365/iw\,172/ih))/2" out1.mp4
But now to reduce processing time, I want to combine these 2 steps in one. I have read https://trac.ffmpeg.org/wiki/Creating%20multiple%20outputs and make following command
ffmpeg -i in.mp4 -filter:v "scale=iw*min(1170/iw\,300/ih):ih*min(1170/iw\,300/ih), pad=1170:300:(1170-iw*min(1170/iw\,300/ih))/2:(300-ih*min(1170/iw\,300/ih))/2" bigVideo.mp4 \ -filter:v "scale=iw*min(365/iw\,172/ih):ih*min(365/iw\,172/ih), pad=365:172:(365-iw*min(365/iw\,172/ih))/2:(172-ih*min(365/iw\,172/ih))/2" smallVideo.mp4
But it is giving following error
[NULL # 0xaee5440] Unable to find a suitable output format for ' -filter:v'
-filter:v: Invalid argument
so can anyone suggest me how i can solve it?
I tried to run both commands using the following script:
#!/bin/bash
for cmd in "$#"; do {
echo "Process \"$cmd\" started";
$cmd & pid=$!
PID_LIST+=" $pid";
} done
trap "kill $PID_LIST" SIGINT
echo "Parallel processes have started";
wait $PID_LIST
echo
echo "All processes have completed";
You can save it as filename.sh and make executable. after that you need to pass two of more commands as arguments, for example I ran as:
./filename.sh "ffmpeg -i input.mp4 -s 720x480 output1.mp4" "ffmpeg -i input.mp4 -s 1170x480 output2.mp4"
Your command was bit complicated for me so I try to run simple commands using parallel script.

C executable to hex

I am using CLion as IDE. After building the output is an executable file example. What I would like to achieve is make .hex file from it and upload it to my AVR via avrdude. I read and tried some possible solutions here
xxd -p example | tr -d '\n' > example.hex
and
avrdude -u -c usbasp-clone -p atmega8 -P /dev/bus/usb/001/006 -U flash:w:example.hex
but avrdude outputs
avrdude: input file example.hex auto detected as invalid format
avrdude: invalid input file format: -1
avrdude: read from file 'example.hex' failed
Any ideas here?
The tool for extracting sections from an executable and converting them into another format is objcopy.
avr-objcopy -j .text -j .data -O ihex example example.hex
Or if your avrdude is built with ELF support then you can use the executable directly.
avrdude -c usbasp-clone -p atmega8 -U flash:w:example