common_builder.py - Routines shared between the server and WAF build
Imports
These are listed in the order prescribed by PEP 8.
Standard library
Third-party imports
None.
Local imports
None.
Globals
Set up thread-local storage
Simulation scripts and checks
Return the string needed to run a SIM30 simulation.
A string giving the MCU to simulate.
The ELF file to load and simulate.
The name of an output file for UART output.
Additional, optional commands.
Spaces in file names break the simulator.
In SIM30, type ? to get help.
Select the dsPIC33E. From the help:
LD <devicename> -Load Device: dspic30super dspic33epsuper pic24epsuper pic24fpsuper pic24super
Load in the pic24_intro.elf. From the help:
LC <filename> -Load COFF/ELF File
Have the simulator save UART1 IO to a file. From the help:
IO [stdin [stdout]] -Input/Output On (use nul if no stdin and/or stdout)
Reset the processor. From the help:
RP -Reset processor POR
Set a breakpoint at the end of the program (the label _done).
From the help:
BS <location> ...[locations] -Breakpoint Set
Include any other setup (stimulus file, pin assignments, etc.).
Run the program. From the help:
; E -Execute
Quit. From the help:
Q -Quit
Return the string needed to run a simulation under MDB.
A string giving the MCU to simulate.
The ELF file to load and simulate.
The name of an output file for UART output.
Additional, optional commands.
Return the string needed to run a simulation under MDB.
A string giving the MCU to simulate.
See the MDB manual for more information.
Select the device to simulate.
Set up to capture UART 1 output to a file. The simulator produces an error if a file name isn’t given here.
Configure the clock to match the setup in the PIC24 library lib/include/pic24_clockfreq.h named SIM_CLOCK.
The ELF file to load and simulate.
The name of an output file for UART output.
Additional, optional commands.
Specify the path to the output file.
This is required to get the above setting applied.
Load in the program.
Set a breakpoint at the end of the program (the label _done).
Include any other setup (stimulus file, pin assignments, etc.).
Run the program. Wait a time in ms for it to finish.
In case the wait time expired before encountering a breakpoint, halt the simulation.
Remove all breakpoints.
Tell the runner that the simulation is finished.
Exit the simulator. For some reason, it takes a while for MDB to exit. This is commented out, so that mdb will stay running until it’s shut down after running many sims.
MDB starting in MPLAB X v5.35 doesn’t understand Windows-style paths (although using \ instead of does work). It does work with Posix paths.
Get a verification code (a random, 32-bit value).
Returns True if a simulation produced the correct answer.
Run MDB
This function runs a simulation, verifying that the simulation results are correct, using the newer MDB simulator.
Inputs: path_to_elf_binary
Outputs: sim_output_file
A path to the MDB script.
The microcontroller to simulate; for example, “dsPIC33EP128GP502”.
A path to the binary (typically in .elf format) to simulate.
Get or create an instance of the simulator.
If the simulator hasn’t been started, …
… or it died, (re)create it.
Create a temp file for the simulation results. Since the simulator doesn’t close the file after the simulation finishes, it can’t be deleted. Instead, we need a single file to be used for a simulation, read, then truncated.
Start the simulator.
These options must go before the --jar option, meaning they require hand edits to mdb.bat/sh; they can’t be passed as paramters (which are placed after `--jar by mdb.bat/sh.)
Per a conversation with Microchip’s support team, this disables the start-up check for new language packs, which takes several seconds to complete.
Java, by default, doesn’t free memory until it gets low, making this a memory hog. On Windows, it starts up at around 400 MB. This seems to keep it below 600 MB.
Shut down the simulator and end the simulation process.
Remove the simout file.
Delete any previous simulation results.
Run the simulation.
Wait for it to finish by watching stdout.
Read then return the result, starting from the beginning of the file.
Celery config
Provide the Celery configuration.
Use Redis with Celery.
Given that tasks time out in 60 seconds, expire them after that. See result_expires.
This follows the Redis caveats.
1 hour.