2024-03-23 07:39 AM
I am beginner with STM32 microcontrollers and currently building a program on the NUCLEO-F446ZE board in which I would like to open a .bin file and parse the data from this file. So far, I fail to open the file.
To check whether my code was the problem or not, I tried to open the .bin file using VS Code. Here, it succeeded, so the code by itself is not the problem. This is the code I wrote:
When debugging my code in the STM32CubeIDE, I notice the following error related to the 'file' variable:
0x20020000 <error: Cannot access memory at address 0x20020000>
Where is this coming from and how can I solve this error?
For info, this is where the .bin file is currently stored:
Thanks in advance!
2024-03-23 08:19 AM
Are you trying to open a file on the PC using semihosting?
2024-03-23 10:42 AM
Hello Pavel,
Thank you for answering. This is the first time I hear about semihosting. What I understand from a quick online search is that it allows an embedded system (i.e., NUCLEO-F446 in my case) to communicate with, and utilize resources of my PC (such as the .bin file, for example). Please correct me if I'm wrong.
So, is semihosting a solution you propose? If yes, could you point me to a good source of further information?
Thanks!
2024-03-23 11:11 AM
@DriesVR94 Yes, if you want to read files from the host via fopen, fread and so on - then the semihosting is a ready solution. But it works only when the debugger is connected, and needs a special runtime library to build with.
See for more details: https://community.st.com/t5/stm32-mcus/how-to-use-semihosting-with-stm32cubeide-and-stm32/ta-p/49742
Keil and IAR IDEs have their own variant of semihosting and build instructions.
.
2024-03-23 11:26 AM
Typically this type of embedded does not provide for a storage medium or file system.
ie You'd need support for MicroSD card and then something like FatFS or FileX
2024-03-23 02:16 PM
Thanks a lot!
I tried this out and it works indeed when debugging. However, when running the code, it doesn't work anymore. It seems like it doesn't even reach the main() function. If indeed it will work only during debugging, and not during runtime, I don't understand the purpose of semihosting in that case. What am I missing here?
To give you some more insight in what I'm trying to accomplish, I want to send an "update" from one NUCLEO-F446ZE to another NUCLEO-F446ZE through a specific communication protocol (which one is not relevant).
My initial plan is to write a simple "update" and create a .bin file from it. Next, I want one of the boards to read this .bin file and transmit its data to the other board.
Any suggestions on how to achieve this are welcome!
2024-03-24 03:44 AM - edited 2024-03-24 03:58 AM
@DriesVR94 There are a lot of uses of semihosting. You can run tests and save logs directly on the host. You can download and program data files without "external loaders" and do custom processing. Finally it can be used to simulate local storage or filesystem that is not ready yet.
> My initial plan is to write a simple "update" and create a .bin file from it. Next, I want one of the boards to read this .bin file and transmit its data to the other board.
Great, just find a way to get the bin file onto one of the boards - from the development PC? or from network?
Recently I've found this thing. It is not only a logger, it can read files from SD-card. Slow, but easy.
2024-03-24 06:56 AM
Ok, interesting.
As a first step, I will try to load the .bin file in an empty sector of the board's Flash memory using the STM32CubeProgrammer (= from the development PC). I think that will get me started for what I want to achieve.
Thanks a lot for all the valuable information!