-
Notifications
You must be signed in to change notification settings - Fork 279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
clean up data structures, remove dynamic memory allocation and make use of Linux compatible lists #135
Conversation
dcee11a
to
26564bd
Compare
Can we also look into changing can_data_t to CAN_HandleTypeDef? This allows easier access to the per channel registers and allows moves the init values into a more standard structure. |
I think the code doesn't make use of |
Now that I reviewed it, it makes more sense for it to roll with the CANFD stuff. |
I'm slowly reviewing this now. Question 1 : at this moment I don't see why you move
|
ACK, we need only 1 instance of
I put the queues/lists and CAN channels into that struct, so it's needed in a header and it can't be static. Doesn't really matter in which file lives...
It's one big driver anyway, isn't it :) For me it was strange to have so many pointers to stuff that was global anyway. |
Fair, I hadn't made it that far. |
But |
Right.
Ah, I was just scrolling through gitk and didn't notice it was a separate branch. Other topic :
Heh, that (and other uses of https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html Alright, this should be good to go. Do you want me to rebase or will you do it ? |
26564bd
to
fa1b0df
Compare
Rebased. One more thing, @ryedwards says debug build are not working anymore. I haven't tried to reproduce the issue here. Maybe debug stuff needs heap? I've increased it from 0 to 512. Still works on my STM32F072. Can someone with a 042 test? |
Oh, I missed that - where ?
works on 3e33589 (current master), and on replace-queues@fa1b0dfa5307151f1c748a029cd05d52d0a21e33 it's broken - not even enumerating. Investigating now. |
There's an IRC channel |
😢 |
In debug mode it would hit the hard fault IRQ even before the debugger had a chance to halt at main(). I was going to try and back out changes and see which commit broke it but I haven't had a chance. Once I get my other stuff merged I'll dive into it. |
The branch should be bisectable. |
I think I have an idea of the issue causing the hardfault. in startup.c :
the for loop runs So the hardfault occurs on a build here with wlen=0x930 , at i=0x601 (thus trying to write at 0x2000 1804 - right outside an F042 's 6kB of RAM !) |
With my setup there is no
Map file generated with this hack (works only if you compile a single firmware): diff --git a/CMakeLists.txt b/CMakeLists.txt
index 77514a2fbb07..8608732b1290 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -38,6 +38,7 @@ add_link_options(
-mthumb
LINKER:--gc-sections
LINKER:--print-memory-usage
+ LINKER:-Map=foo.map
)
add_subdirectory(libs/STM32_HAL) |
b95d707
to
cf9d0a4
Compare
Changes:
|
7b9105b
to
719a7dc
Compare
rebased to new master |
I'm almost done merging - |
e344fb5
to
7f7ddd0
Compare
changes:
|
|
1ac11d7
to
f153cdd
Compare
changes:
|
f153cdd
to
dd749cd
Compare
dd749cd
to
2b0aa91
Compare
changes:
|
[edit] disregard, was on wrong commit |
It turned out, that the locked functions added in 61baf8c ("list.h: add locked variants") are not needed. Remove these and replace them by locked variants of functions needed in the upcoming patches.
Since 8b3a7b4 ("Always queue frames to the host in order") send_to_host_or_enqueue() always enqueues the frame to the q_to_host. In order to make the patch that converts to Linux compatible lists smaller, replace send_to_host_or_enqueue(...) by queue_push_back(q_to_host, ...). Suggested-by: fenugrec <fenugrec@users.sourceforge.net>
The next patch will replace the queue by a list and embed the list head into the hGS_CAN. This is a preparation patch to make the diff smaller.
Convert from the queue implementation to a Linux compatible list implementation. Get rid of This way we can avoid dynamic memory allocation altogether. As the struct gs_host_frame is not placed into the data segment, requirements for the static memory grows. On the low end processors the heap reserved in the linker file is too big, resulting in a linker error. On STM32F042 and STM32F072 set a HEAP size of 0 bytes.
2b0aa91
to
0b52b4e
Compare
rebased to latest master |
I ran canfdtest and cansequence for about 1h each in both directions. All seems well here. Everything still good at your end ? I'll probably tag a release on the commit just before the -O2 / -Os change, as we're adding more serious changes |
Sounds like a plan! |
Merged. Thanks for your diligent rebasing ! |
This patch series cleans up the existing data structures and removed dynamic memory allocation entirely from the code. Last but not least the queue implementation is replaced by a Linux compatible list implementation.
On a STM32F072 the max TX CAN-Bus load (1 Mbit/s, DLC=1) increased from 77% to 87%. A 100% loaded bus can RX'ed without problems before and after the change.