How to halt a target device with pyocd? - embedded

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

Related

Ansible: playbook times out gatherthing facts

So, just getting started with Ansible. I'm trying to run a simple playbook to install Apache2 on a Raspberry Pi, adapted from this example from Digital Ocean. I can ping the machine and ssh in without issues. However, the script seems to stall indefinitely at the gathering facts stage. The last bit of output from running the command with the -vvv flag is this
SSH: EXEC sshpass -d42 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'User="Nizz0k"' -o ConnectTimeout=10 -o ControlPath=/Users/Nizz0k/.ansible/cp/23ecd22287 192.168.0.45 '/bin/sh -c '"'"'echo ~Nizz0k && sleep 0'"'"''
So, I can guess that something is sending the script to sleep, but I have no idea why. Any pointers in the right direction would be greatly appreciated.

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".

OpenOCD read_bank command asks for more arguments

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.

Ansible: "Failed to connect to the host via ssh" error

I'm trying to get set up with Ansible for the first time, to connect to a Raspberry Pi. Following the official 'getting started' steps, I've made an inventory file:
192.168.1.206
.. but the ping fails as follows:
$ ansible all -m ping -vvv
No config file found; using defaults
<192.168.1.206> ESTABLISH SSH CONNECTION FOR USER: pi
<192.168.1.206> SSH: EXEC ssh -C -q -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=pi -o ConnectTimeout=10 -o ControlPath=/Users/username/.ansible/cp/ansible-ssh-%h-%p-%r 192.168.1.206 '/bin/sh -c '"'"'( umask 22 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1464128959.67-131325759126042 `" && echo "` echo $HOME/.ansible/tmp/ansible-tmp-1464128959.67-131325759126042 `" )'"'"''
192.168.1.206 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh.",
"unreachable": true
}
This looks the same as this question, but adding password/user bits make no effect for me, shouldn't be necessary to ping, and aren't in the official example anyhow. In any case I'd prefer to configure Ansible to use a specific public/private key pair (as per ssh -i ~/.ssh/keyfile method..)
Grateful for assistance.
Oh and yes the Raspberry is available at that address:
$ ping 192.168.1.206
PING 192.168.1.206 (192.168.1.206): 56 data bytes
64 bytes from 192.168.1.206: icmp_seq=0 ttl=64 time=83.822 ms
Despite what its name could suggest, Ansible ping module doesn't make an ICMP ping.
It tries to connect to host and makes sure a compatible version of Python is installed (as stated in the documentation).
ping - Try to connect to host, verify a usable python and return pong on success.
If you want to use a specific private key, you can specify ansible_ssh_private_key_file in your inventory file:
[all]
192.168.1.206 ansible_ssh_private_key_file=/home/example/.ssh/keyfile
It works for me.
10.23.4.5 ansible_ssh_pass='password' ansible_user='root'
You can also troubleshoot by executing ssh in debug mode and compare the results when running:
ssh -v pi#192.168.1.206
with:
ansible all -m ping -vvvv

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