-
Notifications
You must be signed in to change notification settings - Fork 83
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
Hacks and fixes to enable picolibc CI on MSP430 #67
base: master
Are you sure you want to change the base?
Conversation
Provide lots more space for programs. This doesn't match the real hardware anymore ... Signed-off-by: Keith Packard <[email protected]>
Use hex20 instead of hex16 to dump the full 20-bit value of each register. Signed-off-by: Keith Packard <[email protected]>
When an exception happens, dump the failing instruction. Signed-off-by: Keith Packard <[email protected]>
This controls whether the simulator runs as fast as possible or pauses to make the execution time more realistic. The default is enabled, disable by passing -realtime=false on the command line. Signed-off-by: Keith Packard <[email protected]>
Only providing 16 bits doesn't work well Signed-off-by: Keith Packard <[email protected]>
This shows an application stack trace. Signed-off-by: Keith Packard <[email protected]>
Provide exit, putchar, a message writing function and a register dump call. These all work by detecting writes to the status register which are invalid. Signed-off-by: Keith Packard <[email protected]>
Disables startup messages Signed-off-by: Keith Packard <[email protected]>
This enables the console stream command handler. It is enabled by default, disable with -console=false Signed-off-by: Keith Packard <[email protected]>
Redirects USCI A0 to stdout when -nogui is enable. Signed-off-by: Keith Packard <[email protected]>
Check for operand size when masking src value before subtraction. Signed-off-by: Keith Packard <[email protected]>
@@ -48,11 +49,13 @@ public class MSP430 extends MSP430Core { | |||
private int[] execCounter; | |||
private int[] trace; | |||
private int tracePos; | |||
private int prevPc = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to initialize this one, 0 is the default value for fields of numeric types.
char c; | ||
System.out.printf("0x%x 0x%x: ", reg[0], message); | ||
try { | ||
int off; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the declaration of off can be in the for-header.
@@ -454,10 +456,50 @@ public void writeRegister(int r, int value) { | |||
* Yet, this has been observed at least once with msp430-gcc 4.6.3. */ | |||
System.out.println("Warning: tried to write odd PC, not allowed! PC=0x" + Integer.toHexString(value)); | |||
value -= 1; | |||
} | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accidental whitespace change.
} else { | ||
// Send serial output to stdout | ||
IOUnit usart = cpu.getIOUnit("USCI A0"); | ||
if (usart instanceof USARTSource) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can become if (usart instanceof USARTSource usartSource) {
in the Cooja repository, and the line with the cast below omitted.
All the changes look reasonable from a quick glance, but the source code for MSPSim silently moved into the Cooja repository (https://github.com/contiki-ng/cooja) a while ago. We need to update README.md with that information. I started writing some explanations, but the MSPSim entry-point is only half-integrated with the Cooja entrypoint. That headache is not yours, can we gradually cherry-pick these patches (or equivalents) into the MSPSim that lives in the Cooja repository? |
I'm probably going to abandon this series as the binutils-gdb simulator is already integrated into the crosstool-ng toolchain, making that far easier to add to the picolibc CI environment. Please feel free to do whatever you like to these patches. |
Here's a series of hacks I wrote which allow me to use mspsim to run picolibc tests. There's only one actual fix here -- extending the CG3 -1 value to 20 bits. Everything else just makes the Tyndall emulator capable of working in picolibc CI.