Eclipse: Need to update some register prior to downloading bin file - eclipse

I'm using Eclipse Oxygen (4.7.3a) for an embedded C work project. There are multiple processors and I'd like to configure some registers prior to downloading the binary image. Eclipse/Debug Configuration/Startup has a Run/Restart Command area which allows commands (like register writes) to be run. I cannot find what this script register write format is.
I have tried:
monitor memU32 0x22002222=0x0005A5AF
It then error with: invalid command name "memU32". Is there a description of what the expected format is? I found this script in a different project, but it doesn't seem to work.
My goal is to be able to set a register to a value, prior to downloading the binary image to RAM.

The 'set' command can be used to set register values. The Debugger Command window appears to link to the GDB, therefore the GDB commands are used here.
set *((int *) 0x22002222)=0x0005A5AF

Related

Where are the files defining NVIC for STM32 in PlatformIO when using CubeMX?

I've recently switched to using PlatformIO for developing for STM32 using the following workflow:
Create a .ioc file using the CubeMX utility
Generate source code and the PlatformIO configuration from that .ioc file from the stm32pio command line utility
Edit, build, and debug using the PlatformIO plug-in for VSCode (Mac)
Overall, this works very well. However, I was previously using the CubeMX code generation in ST's CubeMX IDE, which placed a .s file in the source directory that (as I understand it) defined the NVIC, as well as the default function that was used for exceptions/interrupts that are not explicitly defined (i.e., those handled by their default weak implementations.) I don't see where this is defined in the new workflow. Is this generated dynamically as part of the build process?
The reason I'm asking is (beside wanting a better understanding of the process overall), I'd like to write an interrupt handler for EXTI0, but trigger it as a software interrupt, and not assign a pin to it. If that is not possible, then perhaps the entire point is moot.
I was able to find the answer. These steps might be useful to somebody else who comes across this question. This was done on MacOS, but should be similar to the process for other operating systems.
During the build process, the filename can be seen. It will be prefaced with startup_, followed by the name of the particular chip you're developing for. In my case, the line is
Compiling .pio/build/disco_f072rb/FrameworkCMSISDevice/gcc/startup_stm32f072xb.o
Searching in the .platformio folder of my user directory, I found the matching .s file, which in my case was .platformio/packages/framework-stm32cube/f0/Drivers/CMSIS/Device/ST/STM32F0xx/Source/Templates/gcc/startup_stm32f072xb.s
The structure of the path leading to the file indicates the particulars of the hardware and frameworks I'm using: STM32Cube framework, a F0 series chip, and the GCC compiler. The easiest way to find this file, and how I was able to find it, is using the find command from the terminal to search the PlatformIO directory.
Reading this file gives the lines I was looking for, defining the names of the functions to be used for exception and interrupt handling, such as the following:
.weak EXTI0_1_IRQHandler
.thumb_set EXTI0_1_IRQHandler,Default_Handler
It seems like, while I am using the CubeMX HAL for some drivers, the basic startup code is done using CMSIS, so it should be the same for HAL, LL, or CMSIS based builds.

How to fix 'Unable to open file' when uploading to STM32 in TrueStudio

I am attempting to upload my written program for the STM32F411RE from my TrueStudio for STM32 IDE to the board itself. The board is connected via the mini USB b cable and the intent is to program it via SWD.
Setup
Atollic provides a nice tutorial on how to perform this programming via it's TrueStudio IDE and the ST-Link_CLI (Command Line Interface), as described in the document at this link. This requires the following steps, which I have followed and checked multiple times:
First and foremost the output (binary) file needs to be an intel .HEX and
not the TrueStudio .elf default. To change this go to Project properties -> c/c++ build -> settings -> tool settings tab -> other -> Output format
and tick the option 'Convert build output', ensure that the Intel Hex
option is selected in the dropdown.
To call the ST-Link_CLI from inside the IDE requires making an external
tools configuration. To make this config I go to Run -> External Tools ->
External Tools Configurations .... and create a new configuration, lets
call it ST-Link_CLI. For the Working Directory I specify the directory of my ST-LINK_CLI
(C:\Program Files (x86)\STMicroelectronics\STM32 ST-LINK Utility\ST-LINK Utility)
whilst for the Location I specify this directory and the file name
(C:\Program Files (x86)\STMicroelectronics\STM32 ST-LINK Utility\ST-LINK
Utility\ST-LINK_CLI.exe).
Lastly, I add the following parameters to
identify the STM32 board, have it connect via SWD and under reset, whilst
telling it to upload the .HEX file built by TrueStudio
(-c ID=0 SWD UR LPM -P ${project_loc}\Debug\${project_name}.hex -v).
Output
When I then call this external tool configuration via the Run -> External Tools -> ST-Link_CLI link just created I get the output listed below:
STM32 ST-LINK CLI v3.4.0.0
STM32 ST-LINK Command Line Interface
ST-LINK SN: 066EFF525750877267092042
ST-LINK Firmware version: V2J33M25
Connected via SWD.
SWD Frequency = 4000K.
Target voltage = 3.3 V
Connection mode: Connect Under Reset
Reset mode: Hardware reset
Debug in Low Power mode enabled
Device ID: 0x431
Device flash Size: 512 Kbytes
Device family: STM32F411xC/E
Loading file...
Unable to open file!
Clearly the ST-Link_CLI is succesfully called from inside the IDE, but it somehow cannot digest the .hex file (inside the debug folder) and upload it to the STM32 board.
Even flashing a completely new generated project from CubeMX and setting the options above (including setting it to a .hex file) will not let this toolchain upload it to the board.
Manual code flashing
I have been able to succesfully upload the .HEX file built by TrueStudio via manually uploading it to the STM32 Board with the use of the ST-Link GUI, so I do not think the problem is in the ST-Link itself. I cannot however debug it in this manner, since I need the TrueStudio IDE tools for that and thus need the external tool configuration to work succesfully.
Instead I suspect the issue lies with my own setup, where is somehow is missing a call or has an option set incorrectly. It could also be that the GUI and CLI clients operate in a completely different fashion allowing one to read and upload the file whilst the other cannot, but that seems unreasonable to me.
I am kind of at a loss here however, as I cannot seem to figure out why others can make this work via the provided Atollic documentation and mine is throwing up these errors.
You try to reinvent the wheel using the triangle.
Everything is configured in the TrueStudio:
Just in add the debug configuration and you are done.
What benefits would OpenOCD offer at this point
One essencial : debugging
given how much I have already learned about TrueStudio?
This knowledge (how to configure external tools etc) is rather useless in 99.9999% of circumstances. It is only the configuration of the Eclipse. Not too complex actually needed here.
In regards to my own code, I have not been able to get the ST-Link_CLI to work as an external tool the way I intended, [but I have been able to get the STCubeProgrammer (CLI) to work in the same respective manner as I was attempting to do with the ST-Link].(http://gotland.atollic.com/resources/applicationnotes/AN1801_cubeprogrammer_in_truestudio.pdf).
Seeing as I literally used the same procedure as before but instead specifying the location and executable for the STCubeProgrammer (rather than the ST-Link), I suspect the issue may indeed be the ST-Link CLI (connection to TrueStudio).
It now uploads successfully and immediately after boots me into the debug environment of TrueStudio :)
I simply commented "load" command in the startup script and debugging worked. I only had to load the hex using the st link first.
/# Load the program executable
#load <---//added "#"

Creating VSCode Debugger Extension

I'm in the process of trying to write a VSCode extension to support basic SNES application development. I already have a basic grammar definition and build task, so I have syntax highlighting, and am able to build my project with Ctrl+Shift+B using the bass v14 assembler, but now I'm trying to figure out how to launch the project using launch.json. I've already worked through the official docs and played around with the mock debugger project, but I can't seem to figure out how to adapt it for my extension. To start, I'm using the bsnes-plus emulator as my debugger. There isn't really any command-line or IPC interface that will actually allow me to implement a proper debug adapter, so all I really want to do is to run the program and pass it my output file to launch. For the time being, I'm assuming that bsnes-plus.exe is located in my $PATH, but eventually I'll try and figure out the best practices for external executable dependencies for an extension.
So here are my current questions:
Is the "program" field of launch.json my compiled application, or is it bsnes-plus.exe?
If "program" is my application, where do I specify bsnes-plus.exe? Or vice versa.
Is there a way to specify my own project-level variables, e.g. $OUTPUT so that I don't have to hard-code the output filename into both the build task and the launch task?
At one point, I was able to get the launch command to open bsnes-plus, but not load the game, and when I closed it, VSCode complained that the debugger terminated unexpectedly and immediately re-opened bsnes-plus. How do I avoid this? Do I need to write a debug adapter even though it's not going to actually do anything other than launch the application, just so I can tell VSCode that it exited cleanly?
Is the "program" field of launch.json my compiled application, or is it bsnes-plus.exe?
This is entirely up to the debug extension. It's just passed through to the debug adapter. It usually corresponds to the specific app/script being debugged though, not the runtime that's running it, so I would suggest it should be your compiled application.
If "program" is my application, where do I specify bsnes-plus.exe? Or vice versa.
You can put it any other field. In Dart, we have a dartPath field that can be passed through to the debug adapter. It's usually populated silently by the DebugConfigurationProvider.resolveDebugConfig though (we detect the SDK by searching PATH) so the user never needs to add it.
Is there a way to specify my own project-level variables, e.g. $OUTPUT so that I don't have to hard-code the output filename into both the build task and the launch task?
You can't make your own variables, but using resolveDebugConfig you can manipulate the launch config yourself before it's passed to the debug adapter, which probably allows you to do what you need here (eg. you could do a string replace on program - or you could even just add it if it's not set, allowing a launch.json-less launch too).
Do I need to write a debug adapter even though it's not going to actually do anything other than launch the application, just so I can tell VSCode that it exited cleanly?
I'm not sure what happened here without more details, but having a debug adapter probably makes the most sense - for example if you want to make the Stop/Restart buttons work on the toolbar, you'd probably want a debug adapter that can terminate and/or restart the process.

Commands fail - cannot load ntsdexts

I'm new to using WinDbg and am running into a problem. I've set the server for symbols and downloaded them, but I keep getting stuck when I try to run !htrace (or any other command actually). The error message I get is
Cannot load 'ntsdexts'
I get this on any command that starts with an exclamation point (i.e. !drivers, !heap, !htrace, etc.) which is making tracking down a handle leak a problem.
I'm using the srv*...* link direct to Microsoft for symbols.
The last line before I get the breakpoint is:
Module Load: C:\WINDOWS\SYSWOW64\VFRCORE.DLL (no symbols loaded)
From the comments:
Somehow I managed to get two different version of windbg installed and the one in the path is the wrong one. Put the dll file into the right place, ran from that specific directory and now it works.

Matlab standalone app that was compiled using Guide and deploy tool does not work as designed when deployed

I am not sure if this info helps, but my GUI tool has text boxes for user input, push buttons, drop downs, and an axes to show histogram plot.
The deployment machine is a Windows 7 64 bit. The MCR is installed without any issues (using mcr file packaged with the GUI). The GUI opens in deployed machine. However it does not function properly. Just gives beep sound when using any functionality like pressing a button, no error messages are shown.
I ran the exe file through the dependency walker, and it shows the following errors:
API-MS-WIN-APPMODEL-RUNTIME-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-ERROR-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-ROBUFFER-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-STRING-L1-1-0.DLL
API-MS-WIN-SHCORE-SCALING-L1-1-1.DLL
DCOMP.DLL
IESHIMS.DLL
LAUNCHERMAIN.DLL
(Error opening file. System cannot find the file specified) for all the above.
Run the executable from a dos window in order to obtain all messages that normally would write to matlab console ...
I'm suspecting that some matlab routines used in your buttons were not embedded during compilation (and the beep corresponding to "warning, error in gui callback function "lalala" is undefined).
NB: I don't think there is any issue for missing dll in dependency walker ... else your exe would not run at all and would wrote "Failed to load module".
You are likely missing the Visual Studio redistributable package. Download and install it on the deployed machine.