Flash and debug STM32F7 discovery with openocd - debugging

I recently bought an STM32F7 discovery board [1], and I am therefore trying to flash it using openocd, since the board has an embedded st-link debugger. I have my toolchain working (I am using makefiles and arm-none-eabi-gcc), but I would like to flash the board using eclipse so I can have a graphical debugger.
In order to do so, I installed openocd from their git repo and I launch it with the following config file :
source [find board/stm32f7discovery.cfg]
And then I use the following commands in eclipse with arm-none-eabi-gdb to flash the board :
target remote localhost:3333
monitor flash protect 0 0 11 off
monitor flash erase_address 0x08000000 0x100000
monitor flash write_image erase "/absolute/path/hello-world.hex" 0 ihex
monitor reset halt
I tried different list of commands, including th one from the tutorial I used to set up my debug chain on eclipse [2] or from other SO posts [3][4]. Sometimes the write operation fails, and when it doesn't I end up with a wrong PC (e.g. 0xfffffffe instead of 0x080004ac which is the address if the reset handler). Therefore the CPU will try to execute something that doesn't even exist (outside my memory) and it fails.
Do you have any idea of what might be wrong ? A small precision : I am working on Linux.
Cheers,
Antoine.
[1] : www.st.com/web/en/catalog/tools/FM116/SC959/SS1532/LN1848/PF261641?sc=stm32f7-discovery
[2] : vedder.se/2012/12/debugging-the-stm32f4-using-openocd-gdb-and-eclipse/
[3] : stackoverflow.com/questions/5535110/stm32-gdb-openocd-commands-and-initialization-for-flash-and-ram-debugging
[4] : stackoverflow.com/questions/17003519/stm32f4discovery-openocd-telnet-uploading-demo-program
[5] : github.com/texane/stlink
[Edit]
I also tried to use an st-link program from github [5] and to load with gdb, and I get a similar error :
2016-03-23T09:22:22 INFO src/stlink-common.c: Attempting to write 32768 (0x8000) bytes to stm32 address: 134217728 (0x8000000)
2016-03-23T09:22:22 WARN src/stlink-common.c: Failed to unlock flash!
EraseFlash - Sector:0x0 Size:0x8000
Flash page at addr: 0x08000000 erased
2016-03-23T09:22:22 INFO src/stlink-common.c: Finished erasing 1 pages of 32768 (0x8000) bytes
2016-03-23T09:22:22 INFO src/stlink-common.c: Starting Flash write for F2/F4/L4
2016-03-23T09:22:22 INFO src/stlink-common.c: Successfully loaded flash loader in sram
enabling 32-bit flash writes
size: 32768
2016-03-23T09:22:23 INFO src/stlink-common.c: Starting verification of write complete
2016-03-23T09:22:23 ERROR src/stlink-common.c: Verification of flash failed at offset: 0

I managed to solve the problem. It turns out I must have modified the internal option bytes, and this was blocking me when I was trying to flash the board.
I used st-link utility to set them back to their default values, and now everything is working fine ! It is probably possible to use openocd instead, but I haven't tried yet. If someone knows how to do it, it would be nice of him to share it.
For more details on the option bytes, you can have a look at the reference manual [1], page 80 to 83.
[1] : http://www.st.com/st-web-ui/static/active/en/resource/technical/document/reference_manual/DM00124865.pdf

Related

TwinCAT 3.1 fCoE read and write with Complete Access

I am attempting to perform complete access read and writes to an EtherCAT slave controller using TwincAT 3.1 on Windows 10.
Generated EtherCAT Slave Stack Code using the Beckhoff Slave Stack Code Tool 5.12. Successfully able to enter operational state using TwinCAT 3.1 as EtherCAT master. I have a mailbox object at index 0x8001, which is an array of 25 bytes. I am unable to perform complete access, which allows writing / reading all 25 bytes from the object at 0x8001. Without the complete access, I will have to write to each sub-index of the index 0x8001 individually.This means 25 separate read/ write operation at each sub-index under the object.
I have tried using EC Engineer 3.06 from Acontis technologies as EtherCAT master, and I verified that the complete accesses are functional.
Does anyone know how to perform complete access using TwinCAT?
Twincat does it automatically if the ESI file has the complete access flag.

Periodic tns-12531: TNS: Cannot allocate memory

I have a problem that's been plaguing me about a year now. I have Oracle 12.1.x.x installed on my machine. After a day or two the listener stops responding and the listener.log contains a bunch of TNS-12531 messages. If I reboot, the problem goes away and I'm fine for another day or two. I'm lazy and I hate rebooting, so I decided to finally track this down, but I'm having no luck. Since the alternative is to do work that I really don't want to do, I'm going to spend all my time researching this.
Some notes:
Windows 10 Pro
64-Bit
32 GB RAM
Generally, about 20GB free when the error occurs
I have several databases and it doesn't matter which DB is running
Restarting the DB doesn't help
Restarting the listener doesn't help
Only rebooting clears the problem
When I set TRACE_LEVEL_LISTENER = 16, I don't get much more info. Trace files are not written to
I can connect to the DB if I bypass the listener (ie, set ORACLE_SID=xxx and connect without a DB identifier)
All other network interactions seem to work fine after the listener stops
lsnrctl status hangs and adds another TNS-12531 to the listener.log
I have roughly the same config at home and this does not happen
Below is an example of a listener.log file:
Fri Jul 28 14:21:47 2017
System parameter file is D:\app\user\product\12.1.0\dbhome_1\network\admin\listener.ora
Log messages written to D:\app\user\diag\tnslsnr\LJ-Quad\listener\alert\log.xml
Trace information written to D:\app\user\diag\tnslsnr\LJ-Quad\listener\trace\ora_24288_14976.trc
Trace level is currently 16
Started with pid=24288
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=LJ-Quad)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1521ipc)))
Listener completed notification to CRS on start
TIMESTAMP * CONNECT DATA [* PROTOCOL INFO] * EVENT [* SID] * RETURN CODE
28-JUL-2017 14:22:06 * 12531
TNS-12531: TNS:cannot allocate memory
28-JUL-2017 14:22:47 * 12531
TNS-12531: TNS:cannot allocate memory
28-JUL-2017 14:26:24 * 12531
TNS-12531: TNS:cannot allocate memory
Thanks a bunch for any help you can provide!
Issue 1
This error can occur approximately after 2048 connections have been made via the listener when running on a non-English Windows installation.
Fix for Issue 1
Create a Windows User Group named Administrators on the computer where the listener.exe resides. This can fix the issue of the listener dying.
Reference: I'll post the link for the first issue as soon as I find it again
Issue 2
This error can also occur on Windows 64-Bit systems where the Desktop Application Heap is too small.
Fix for Issue 2
Try to Increase the Desktop Application Heap Registry in windows its located in
HKLM\System\CurrentControlSet\Control\Session Manager\SubSystems\Windows
Just as note don't add this Value by yourself, you have to depend on document.
Basically search for the registry entry and alter the third value for the key SharedSection=1024,20480,1024. This is a trial and error approach, but seems to improve listener's stability and memory issues.
Reference: TNS:cannot allocate memory - is there limit to the num databases on one box (Oracle Developer Community)

Boot Linux in Normal World

I am exploring the TrustZone (the ARM security extension) on an i.MX53 Quick Starting Board. I succeeded to make a bare-metal system : A secure world image and a normal world image. I load the two images in my ram with u-boot and I boot the secure world who initializes the monitor system and gives the hand to the normal world image.
I want to use the same system. But this time instead of using a normal world basic image, I would like to use a Linux Kernel Image. I did some configurations that I found in the i.MX53 Reference Manual and the i.MX53 Security Reference Manual when I am in the secure world. The configurations are :
Configure the CSU : CSL0-31 to 0x00FF_00FF
Configure the TZIC (interrupts) TZIC_INTSEC0-3 to 0xFFFF_FFFF, TZIC_PRIORITY0-31 to 0x1F1F_1F1F and TZIC_INTCTRL to 0x8001_0001
Configure Secure Configuration Register : NS=0 IRQ=0 FIQ=0 EA=0 FW=1 AW=1 => 0x30
When I give the hand to the linux kernel, the boot process starts, here is a part of the output :
regulator: core version 0.5
NET: Registered protocol family 16
i.MX IRAM pool: 128 KB#0xec840000
FAILED TO RELEASE IRAM PARTITION
CPU is i.MX0 Revision 0.0
Unhandled fault: external abort on non-linefetch (0x1008) at 0xec82c00c
Internal error: : 1008 [#1] PREEMPT
last sysfs file:
Modules linked in:
CPU: 0 Not tainted (2.6.35.3 #1)
PC is at mxc_cpu_lp_set+0x1c/0x16c
LR is at arch_idle+0x60/0x294
pc : [<8003a958>] lr : [<8003ab08>] psr: 60000093
sp : 80835f78 ip : 00000003 fp : 8088fb68
....
As you can notice in the output, there is a problem with the IRAM (because normally it diplays IRAM READY) and there is a data abort. After so displays related to these errors, the Linux kernel boot process stops.
Any ideas of how to solve that ? Am I missing any configuration ? Thank you
Have you seen this post on the Freescale forum?
It seems to be the exact same problem you're having. Basically, it is probably trying to access a register, at 0xec82c00c virtual address, which is configured by default to be non-accessible from the Normal world.

Debugging Linux Kernel Module

I have built a linux kernel module which helps in migrating TCP socket from one server to another. The module is working perfectly except when the importing server tries to close the migrating socket, the whole server hangs and freezes.
I am not able to find out the root of the problem, I believe it is something beyond my kernel module code. Something I am missing when I am recreating the socket in the importing machine, and initializes its states. It seems that the system is entering an endless loop. But when I close the socket from client side, this problem does not appear at all.
So my question, what is the appropriate way to debug the kernel module and figure out what is going on, why is it freezing? How to dump error messages especially in my case I am not able to see anything, once I close the file descriptor related to the migrated socket in the server side, the machines freezes.
Note: I used printk to print all the values, and I am not able to find something wrong in the code.
Considering your system is freezing, have you checked if your system is under heavy load while migrating the socket, have you looked into any sar reports to confirm this, see if you can take a vmcore (after configuring kdump) and use crash-tool to narrow down the problem. First, install and configure kdump, then you may need add the following lines to /etc/sysctl.conf and running sysctl -p
kernel.hung_task_panic=1
kernel.hung_task_timeout_secs=300
Next get a vmcore/dump of memory:
echo 'c' > /proc/sysrq-trigger # ===> 1
If you still have access to the terminal, use the sysrq-trigger to dump all the stack traces of kernel thread in the syslog:
echo 't' > /proc/sysrq-trigger
If you system is hung try using the keyboard hot keys
Alt+PrintScreen+'c' ====> same as 1
Other things you may want to try out, assuming you would have already tried some of the below:
1. dump_stack() in your code
2. printk(KERN_ALERT "Hello msg %ld", err); add these lines in the code.
3. dmesg -c; dmesg

Linux Source code location of interface configuration(eth)

My requirement is to implement(insert ) an ip address validation step in kernel.. Once any of the interface is up and got ip, then my validation should happen..
So as the first step , in source code (linux 2.6 source code I downloaded ) , in which file I need to trace
The kernel is the wrong place for this unless you're doing something embedded with a teeny tiny footprint. What you really want is ifplugd.
However, if you absolutely insist on having it be in the kernel - take a look at the kernel bits that get enabled when CONFIG_IP_PNP=y

Resources