Skip to content

Conversation

@keith-packard
Copy link

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.

Provide lots more space for programs. This doesn't match the real
hardware anymore ...

Signed-off-by: Keith Packard <keithp@keithp.com>
Use hex20 instead of hex16 to dump the full 20-bit value of each register.

Signed-off-by: Keith Packard <keithp@keithp.com>
When an exception happens, dump the failing instruction.

Signed-off-by: Keith Packard <keithp@keithp.com>
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 <keithp@keithp.com>
Only providing 16 bits doesn't work well

Signed-off-by: Keith Packard <keithp@keithp.com>
This shows an application stack trace.

Signed-off-by: Keith Packard <keithp@keithp.com>
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 <keithp@keithp.com>
Disables startup messages

Signed-off-by: Keith Packard <keithp@keithp.com>
This enables the console stream command handler. It is enabled by
default, disable with -console=false

Signed-off-by: Keith Packard <keithp@keithp.com>
Redirects USCI A0 to stdout when -nogui is enable.

Signed-off-by: Keith Packard <keithp@keithp.com>
Check for operand size when masking src value before subtraction.

Signed-off-by: Keith Packard <keithp@keithp.com>
private int[] execCounter;
private int[] trace;
private int tracePos;
private int prevPc = 0;
Copy link
Contributor

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;
Copy link
Contributor

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.

System.out.println("Warning: tried to write odd PC, not allowed! PC=0x" + Integer.toHexString(value));
value -= 1;
}
}
Copy link
Contributor

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) {
Copy link
Contributor

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.

@pjonsson
Copy link
Contributor

pjonsson commented Sep 9, 2023

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?

@keith-packard
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants