2019-05-11 11:15 AM
Hi, I'm installing USB VCP communication, I generated the project with CubeMx, my board is configured as a device and I loaded the virtual com port as a Class for FS IP.
It happens that by compiling the program with GCC (True Studio) the "FS_Desc" structure is not loaded into ram (all pointers are at 0) and consequently when trying to use this structure the program crashes (Hard Fault).
The same program compiled with Keil works perfectly ...
Does anyone have any idea what happens?
I attach the True Studio screenshot with the breakpoint where the crash occurs.
2019-05-11 03:04 PM
The startup module is wrong or missing? Link script is wrong?
> The same program compiled with Keil works perfectly ..
This is why we like Keil. It usually Just Works. Unlike some "free" stuff which costs nothing upfront, but later we pay more with our time and effort.
-- pa
2019-05-12 03:26 AM
I agree but free studio is a professional tool .....
The strange thing is that the FS_Desc structure is correctly viewed by Free Studio ...
2019-05-12 05:22 PM
Then maybe the problem is in the startup module (the assembly one); it is responsible for initializing static data.
-- pa
2019-05-13 12:43 AM
Hi Pavel, thanks again for your reply.
I found the problem, it is a misalignment between LMA, VMA
and loader, in fact I introduced in the linker script (.ld) an offset of 0x400 bytes and this can be seen in the screenshot where the initial VMA address for .data is 0x20000000 but the address of the first variable (ERT) is at 0x20000408.
However, the loader does not see this offset and only loads 0.4kb in area 0x20000000 ... 0x20000190, leaving all the structures from ERT forward uninitialized.
What I need to do now is instruct the loader that the initial address for the structures to load is 0x20000400 instead of 0x20000000.
I introduced the same offset in the keil scatterload file where I didn't make mistakes ....
Ah .... this is what happens when you use things like .ld and .sct files never used before ......
2019-05-13 08:48 AM
>>Ah .... this is what happens when you use things like .ld and .sct files never used before ......
That and the rather sophomoric implementation of the GNU statics initialization code to unpack the load regions, define the default stack address, and determine the heap size. The irony here is you probably have a better grasp of the end goal than the people that signed that code into the repository..
2019-05-13 11:39 PM
Hi Clive, it may be, I come from a good assembler programming experience.
2019-05-14 01:06 AM
> This is why we like Keil. It usually Just Works. Unlike some "free" stuff which costs nothing upfront, but later we pay more with our time and effort.
Oh please... Linux is free (and in runs the world - servers, super-computers, possibly your smartphone, your fridge, your car, your TV, there's a good chance they all have the Kernel inside), Git is free (literally every developer uses it nowadays), Nginx is free (it runs the majority of web servers), Firefox, Chromium, VLC, PostgreSQL, Redis, OpenCV, Blender, GCC, LLVM/Clang, R, Python... I can continue the list for hours.
Free software is already the present and surely the future of computing (if we don't lose the war on general purpose computing). Even the mastodons of closed/proprietary software embrace it, so go tell that free software stinks to Microsoft's execs, or Oracle's..
2019-05-14 01:13 AM
> rather sophomoric implementation of the GNU statics initialization code
I don't think that the sophomoric code comes from the GNU guys, they develop the compiler/linker/tools, they don't write *.ld or startup code for every processor they support. I just opened a random startup file (startup_stm32l031xx.s) generated by Cube - it isn't GPL licensed, and mentions "MCD Application Team" in the header comments as the author. If I should guess - it's either from ST or Atollic (currently the same thing).