What is the best solution to load the correct gpio mapping for atmega328p in ghidra - ghidra

All the tutorials I found use the default AVR8 default 16 litle gcc configuration when importing the binary.
After importing the file with this configuration the gpio register mapping is completely messed up.
What is the best solution to load the correct gpio mapping for atmega328p in ghidra ?
In the scripts managers we can find CreateAVR8GDTArchiveScript but when I run the script ghidra asks for a location for the output and then errors out because it does not find the avr headers
Where does ghidra look for the avr headers when CreateAVR8GDTArchiveScript is ran ?

Related

How to have the configuration name in the bit file that can be read back after flashing the bit file on to the fpga?

I have 2 bit files say Config_1.bit and Config_2.bit. I would like to have the name of the bit file inside the bit file along with the design because when I would want to know what bit file is already present on FPGA before using the FPGA.Any suggestions or ideas are highly welcome.
Ex: Lets say I have flashed config_1.bit on to the FPGA. Now I want to see the name of the design on my Hyper terminal before running any application.
How can I do that?
Altera's approach is to instantiate the "System ID peripheral" that stores timestamp and 32-bit numeric ID that is pre-set during IP configuration.
You would read that peripheral, either via jtag (this way Nios SBT is checking if the software is compiled for the right system), or embedded system would read it and report through uart/spi/i2c - whatever you will be using with terminal.

debugging issue in ARM stm32f407

while i was using cubemx to set peripherals of my stm32f407 arm core, just before generating code, i checked and selected the "set all free pins as analog (to optimize the power consumption)" dialog box in project settings-> code generator-> HAL settings, without masking the debug pins (swdio and swclk). After that, i downloaded a simple blinky code inside the microcontroller successfully using keil ide. but now when i want to use keil to erase or download a code, i see "no target connected" error in debug tab and i cant download any code. How can i solve this problem? Thanks for your helps.
After about 10 hours searching, i found the solution.
if someone had the same problem, here is the solution :
https://electronics.stackexchange.com/questions/204996/stm32-st-link-cannot-connect-to-mcu-after-successful-programming
As an addition to your answer - when you set all as analog, set in the SYS the correct debug interface. It will prevent code generator from setting those pins as analog.

where to find GCC atmega328 startup code and linkerscript

Where can I find the startup code (crt0.s or whatever it is called) for an Atmega328p (the Arduino uno chip) and the associated linker script for use with avr-gcc?
I know I can rely on the compiler to find the startup, but it seems to be provided only as object code.
Here you go : https://github.com/vancegroup-mirrors/avr-libc/tree/master/avr-libc/crt1
and for the atmega328p:
https://github.com/vancegroup-mirrors/avr-libc/blob/23c47c61adaa52a2851efb162dd17c1db1047a93/avr-libc/crt1/iosym/atmega328p.S
EDIT 2015/01/23:
this is not the arduino bootloader but a better fork (?), maybe you can find what you need here: https://code.google.com/p/optiboot/source/browse/#hg%2Foptiboot%2Fbootloaders%2Foptiboot

Qemu arm Linux kernel boot debug, no source code

I am using Qemu to learn some linux kernel development/hacking and wanted to debug the boot process of Linux (2.6.34.3). I have compiled for the ARM versatile platform and is using Codesourcerys arm-none-eabi crosscompiler. I am using Eclipse as the environment to build and debug using gdbserver.
So I have manged to successfully build and run the kernel in qemu but the problem is that I dont see any source code in the debugger at the boot process(at address 0), I can only see the disassembly code. However, when it switches to virtual memory at init/main.c (address over 0xC0000000), the source code appears and I can see the source code and step through and over code. Why is that? I want that from the beginning.
Anyone have any tips on how to debug the boot process of Linux? All the guides in google shows how to debug the kernel, but they all show from start_kernel() (located in init/main.c) and not from the beginning of the boot process (in arch/arm/boot/compressed/head.S). Anyone with experience help please, thank you!
Looked into the System.map in the root folder and there is only symbols for stuff from c0004000 (where the virtual address start). I load vmlinux into gdbserver to get debug information, Maybe thats why theres no source?
The Linux kernel uses a 2-step booting processing (and this does not include any boot loader like u-Boot ...). You can better understand this especially by looking into 2 .lds files (detailed below) for linking:
arch/arm/boot/compressed/vmlinux.lds.in, which generates arch/arm/boot/compressed/vmlinux.lds.
Along with other .o files in arch/arm/boot/compressed, a vmlinux is generated inside this folder.
You can use arm-none-eabi-nm -a -n arch/arm/boot/compressed/vmlinux to see the symbols for this stage. All addresses are physical addresses.
These symbols are NOT included in System.map
The second vmlinux is generated by kernel .o files and arch/arm/kernel/vmlinux.lds (note: the path is different)
I hope this explains why you can not see the booting source code in Eclipse.
linux kernel is too complex to understand(for a beginner).
Why dont use use a smaller OS like xv6:
OS is small, sourcecode is about 8000 lines
used by many universities
based on V6(unix),
boot process is the same except that its less complicated than that of linux.
Appendix B of the xv6 book deals with boot process(its short and sweet).You can run gdb on qemu and see the boot process, the main files to check out for are bootasm.S(in assembler) and bootmain.c.
This is much simpler and easier to do and understand when compared to linux.(atleast for beginners).There are assingmennts on , setting up qemu , using gdb ,tracking the boot process , doing changes to the source code etc in the link given.Give it a shot :)
Cheers,
sharan
head.S is written in assembly, not C. That's what the .S suffix indicates.

Debug uBoot with JTAG and Trace32?

I am bit new to this field and my query here is a bit vague. I am particularly interested in how any of you, who have had experience with uBoot and a JTAG debugger (like a Lauterbach), have gone about tackling and resolving an issue within uBoot.
Specifically, I would really appreciate if you could describe the problem encountered within uBoot, and how did the JTAG help you resolve the issue.
Thanks,
vj
I have used this many times using Texas Instruments' CCS debugger. I would create a dummy project with the u-boot source code and then attach. Afterward, I can load the u-boot symbols or the u-boot app itself and step through the code. Reloading and restarting u-boot is helpful to work through issues.
This applies to any problem with u-boot, including start-up problems.
I use LPCXpresso (based on Eclipse) to debug U-Boot on my board (with LPC4350 MCU).
But be careful, you could have problem to debug and you maybe need to modify the .lds file (linker script).
You have to find this file but be cautious, the file is copied and modified when you configure the compilation for your board, you have to look for the original file.
Then if you find
/DISCARD/ :
{
*(*)
}
in the .lds file, you won't be able to debug. Just remove it or comment it.

Resources