Your dream ECU
Junior Member
Joined: Feb 2007
Posts: 269
Total Cats: 92
From: 11368 miles from where i would like to be
What I will say is that in my experience, if the maintainers are diligent, community driven projects actually tend to produce MUCH better code than commercial solutions.
<snip>
Having 150 people tell you that your code looks like **** on the internet makes you shape up quick if you want it to be included
There are a lot of problems with the MS codebase.
1) I shouldn't have to dig through 1300 lines of global variables and memory map structures to get to the definition of main() in a file called ms2_extra_main.c.<snip>
2) WHY THE **** ARE THERE SO MANY GLOBAL VARIABLES.<snip>
3) Your main loop shouldn't be 2000 lines long. Y U NO FUNCTION!?! <snip>
4) There is no layering. Good embedded software is layered (in fact, all good software is layered). <snip>
5) Theyoveruse GOTO statements.<snip>
6) They use assembly in completely unnecessary places.<snip>
<snip>
Having 150 people tell you that your code looks like **** on the internet makes you shape up quick if you want it to be included

There are a lot of problems with the MS codebase.
1) I shouldn't have to dig through 1300 lines of global variables and memory map structures to get to the definition of main() in a file called ms2_extra_main.c.<snip>
2) WHY THE **** ARE THERE SO MANY GLOBAL VARIABLES.<snip>
3) Your main loop shouldn't be 2000 lines long. Y U NO FUNCTION!?! <snip>
4) There is no layering. Good embedded software is layered (in fact, all good software is layered). <snip>
5) They
6) They use assembly in completely unnecessary places.<snip>
Standard ms function sig these days is void abc(void) :-) Hilarious. Unless you're a maintainer, or user.
Fred.
Joined: Sep 2005
Posts: 34,402
Total Cats: 7,523
From: Chicago. (The less-murder part.)
Modular high-level code is easy to create and a nightmare to debug.
Irony: my feeble old mind finds the MS1 code much easier to comprehend than the new stuff, since it's all written in assembly as a single, monolithic listing. No need to go chasing through a dozen different .c files while attempting to trace the flow of the code through a typical cycle.
Modular high-level code is easy to create and a nightmare to debug.
Modular high-level code is easy to create and a nightmare to debug.
There are a lot of problems with the MS codebase.
1) I shouldn't have to dig through 1300 lines of global variables and memory map structures to get to the definition of main()
...
2) WHY THE **** ARE THERE SO MANY GLOBAL VARIABLES.
3) Your main loop shouldn't be 2000 lines long. Y U NO FUNCTION!?!
4) There is no layering.
5) They overuse GOTO statements.
6) They use assembly in completely unnecessary places.
1) I shouldn't have to dig through 1300 lines of global variables and memory map structures to get to the definition of main()
...
2) WHY THE **** ARE THERE SO MANY GLOBAL VARIABLES.
3) Your main loop shouldn't be 2000 lines long. Y U NO FUNCTION!?!
4) There is no layering.
5) They overuse GOTO statements.
6) They use assembly in completely unnecessary places.
- Why do you think the devs fell into that?
- Maybe the MS3 is much better?
I agree, however the problem with CAN is that its not suitable for time critical applications. For example, if you want to activate a high-current device at a specific crank angle, you can't. Or to put more scientifically, you can try, but you are not guaranteed to apply it in the correct time frame.
I can't comment on that as all of the community projects I'm involved in are related to embedded systems. What I will say is that in my experience, if the maintainers are diligent, community driven projects actually tend to produce MUCH better code than commercial solutions. People tend to get in a tight feedback loop in their company, with no external criticism, and commit bullshit. Having 150 people tell you that your code looks like **** on the internet makes you shape up quick if you want it to be included 

I've looked at the MS code once or twice, and yeah, it's pretty ugly.
--Ian
I never delved into the MS code, so I didn't realize the above. Early in my working life I've programmed in C for embedded systems. I'm a hardware, not a software weenie (my wares are hard), but your list describes newbie mistakes (I knew enough to avoid), or the classic "hardware engineers writing code" problem.

- Why do you think the devs fell into that?
Can't speak to MS3 as I've not seen the code.
Irony: my feeble old mind finds the MS1 code much easier to comprehend than the new stuff, since it's all written in assembly as a single, monolithic listing. No need to go chasing through a dozen different .c files while attempting to trace the flow of the code through a typical cycle.
Example: on startup, a cortex M3 walks through the data section of the binary and copies the contents from flash to ram.
This is the standard STM CMSIS implementation:
Code:
Reset_Handler:
/* Copy the data segment initializers from flash to SRAM */
movs r1, #0
b LoopCopyDataInit
CopyDataInit:
ldr r3, =_sidata
ldr r3, [r3, r1]
str r3, [r0, r1]
adds r1, r1, #4
LoopCopyDataInit:
ldr r0, =_sdata
ldr r3, =_edata
adds r2, r0, r1
cmp r2, r3
bcc CopyDataInit
ldr r2, =_sbss
b LoopFillZerobss
/* Zero fill the bss segment. */
FillZerobss:
movs r3, #0
str r3, [r2], #4
LoopFillZerobss:
ldr r3, = _ebss
cmp r2, r3
bcc FillZerobss
/* Call the clock system intitialization function.*/
bl SystemInit
/* Call the application's entry point.*/
bl main
bx lr
Code:
void reset_handler(void)
{
volatile unsigned *src, *dest;
for (src = &_data_loadaddr, dest = &_data; dest < &_edata; src++, dest++)
*dest = *src;
while (dest < &_ebss)
*dest++ = 0;
/* Call the application's entry point. */
main();
}

Modular high-level code is easy to create and a nightmare to debug.
Thread
Thread Starter
Forum
Replies
Last Post
bigmackloud
Miata parts for sale/trade
19
Jan 8, 2021 11:24 AM
Motorsport-Electronics
ECUs and Tuning
0
Sep 5, 2015 08:02 AM







