C executable to hex - cmake

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

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

Auditd Error : arch elf mapping not found

I have to add rules in auditd.
It seems to work for recording command (option -w) but not for option -a where arch must be specified.
For example :
$> auditctl -a exit,always -F arch=b64 -S adjtimex -S settimeofday -S clock_settime -k timechange
arch elf mapping not found
$> uname -m
aarch64
The kernel is compiled with
CONFIG_AUDIT=y
CONFIG_AUDITSYSCALL=y
CONFIG_HAVE_ARCH_AUDITSYSCALL=y
Have you got an idea ?
Thanks
The solution was to recompile auditd with the good argument, espicially --with-arm64 during the configure phase.

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.

Open PDF found with volatility

my task is to analyze a memory dump. I've found the location of a PDF-File and I want to analyze it with virustotal. But I can't figure out how to "download" it from the memory dump.
I've already tried it with this command:
python vol.py -f img.vmem dumpfiles -r pdf$ -i --name -D dumpfiles/
But in my dumpfile-directory there is just a .vacb file which is not a valid pdf.
I think you may have missed a command line argumenet from your command:
python vol.py -f img.vmem dumpfiles -r pdf$ -i --name -D dumpfiles/
If you are not getting a .dat file in your output folder you can add -u:
-u, --unsafe Relax safety constraints for more data
Can't test this with out access to the dump but you should be able to rename the .dat file created to .pdf.
So it should look something like this:
python vol.py -f img.vmem dumpfiles -r pdf$ -i --name -D dumpfiles/ -u
You can check out the documentation on the commands here
VACB is "virtual address control block". Your output type seems to be wrong.
Try something like:
$ python vol.py -f img.vmem dumpfiles --output=pdf --output-file=bla.pdf --profile=[your profile] -D dumpfiles/
or check out the cheat sheet: here

What is the equivalent command for objdump in IBM AIX

I am not able to find objdump command in IBM AIX 5.1 machine. Actually I want to get the assembly instructions (disassemble) from a library generated in AIX. Linux has objdump command and solaris dis command to do this. What is the equivalent command in IBM AIX?
You can use the dis command to disassemble object files on AIX, it should come with xlc.
It may be easier to install the GNU bintools suite to just get objdump though. Its available from the AIX linux toolbox.
I have only part of an answer. Following up on #CoreyStup, I found the dis command in /opt/IBM/xlc/16.1.0/exe/dis (not the bin directory). But it was very recalcitrant, and seemed unwilling to print to stdout or stderr. I did find it was writing the output a filename created by replacing the .o on the command line with .s. So:
% /opt/IBM/xlc/16.1.0/exe/dis aix/ktraceback.o
% ls -l aix/ktraceback.s
-rw-r--r-- 1 ota staff 10432 Nov 19 14:01 aix/ktraceback.s
% /opt/IBM/xlc/16.1.0/exe/dis -o /tmp/foo.s aix/ktraceback.o
% ls /tmp/foo.s
-rw-r--r-- 1 ota staff 10432 Nov 19 14:06 /tmp/foo.s
Using strings -a -n2, I was able to extract a possible usage message, but it was unclear what most of the options do, with the exception of -o.
dis disassembler version 1.27.0.1 Nov 9 2018 08:18:36
%s [-D] [-G] [-g] [-h] [-i] [-k] [-L] [-l] [-M] [-m <architecture>]
[-o <file name>] [-p <level>] [-r] [-R] [-S] [-T] [-t] [ filename ]
-D
disassemble .data and .bss only
-G
do not print symbolic debugging information
-g
print symbolic debugging information (default)
-H
print BO branch hints
-h
print headers
-i
line input mode
-k
do not interpret traceback table
-L
print linker section
-l
print line number table
-M
print text maps
-e
print except entries
-m
force architecture selection:
pwr|pwrx|pwr2|pwr2s|p2sc|com|403|601|602|603|603e|604|604e|620|
ppc|ppcgr|ppc64|rs64a|rs64b|rs64c|pwr3|pwr4|pwr4x|pwr5|pwr5x|
pwr6|pwr6e|pwr7|pwr8|pwr9|[ppc]970|440|440d|450|450d
-o
output to file
-p
print level
-R
print relative offsets (no added labels)
-r
print relocation table
-S
suppress printing symbolic definitions
-T
disassemble .text only
-t
print symbol table