The code on this repository runs on the Cortex-M3 core embedded on the SmartFusion2 FPGA.
- Clone this repository/unzip the archive downloaded via GitHub
- Download SoftConsole (any latest version should work)
- Import this project into SoftConsole
- Most of the code is under
main.c
, in thewhile (1)
loop:REQ_HK
data is prepared once a second; the second counting is handled byTimer1
(see alsoTimer1_IRQHandler()
);REQ_PAYLOAD
data is prepared once the DAQ has finished; note that this is a lenghty process (several hundreds of microseconds), especially if histogram binning is performed;- MSP commands are then handled in the next
if
/else if
statements.
- MSP callbacks functions and some ISRs are also present at the bottom of
main.c
. - Other folders under
cubes-fw
contain various APIs for handling devices on the CUBES board.
cubes-fw
firmware // Code generated from Libero
hk_adc // API to handle the ADS1015 ADC
hvps // API to handle the C11204-02 HVPS module
mem // API to handle CUBES memory accesses
msp // MSP API functions, generated using the Python script supplied with MSP
utils // Various utilitary APIs, e.g., to handle the on-board LED
- See firmware/README.md.
- Externally from the
cubes-fw
repository, obtain the MSP repository from GitLab:git clone https://gitlab.com/kth-mist/msp msp-repo
- Copy/move the file
cubes-fw/msp/msp_configuration.h
to somewhere you know; this file will need to replace whatever gets generated by the MSPconf.py
script! - Delete all contents inside the
cubes-fw/msp/
folder; - Use
msp-repo/conf.py
to generate a new set of MSP files; - Copy these files from
msp-repo/target/
tocubes-fw/msp/
. - Copy back the
msp_configuration.h
file you saved earlier over that generated by theconf.py
script.
CUBES should be programmed using a FlashPro5 programmer from Microchip. The standard 10-pin JTAG connector supplied with the FlashPro5 should be adapted to the 1.27-mm pitch programming port on the CUBES board using a 2.54-to-1.27-mm adapter. One such adapter can be found in AlbaNova, in the "PoGO lab" on the bottom floor of the building. The adaptor should be located in the plastic box labeled "CUBES".
Each CUBES board has its own ID, labeled on the top side of CUBES boards, corresponding to
the -Z face of the satellite. The number on this label corresponds to the second character
in the BOARD_ID
macro, defined via a -D
compiler flag:
-
Open the Properties window for the
cubes-fw
project by either right-clicking the project in SoftConsole and pressing Properties in the pop-up menu, or selecting the project in SoftConsole and hitting Alt+Enter on your keyboard. -
Navigate to C/C++ Build > Settings > GNU ARM Cross C Linker > General and double-click the script file:
-
Ensure the
esram
linker script is used for programming: -
Press the Apply and Close button in the Properties dialog.
-
Connect the FlashPro5 programmer to the CUBES PCB of interest.
-
Press the Debug (bug) button on the SoftConsole interface.
-
The code should now be programmed to CUBES volatile memory; HK can be read out from CUBES and checked if it "makes sense".
-
Open the Properties window for the
cubes-fw
project by either right-clicking the project in SoftConsole and pressing Properties in the pop-up menu, or selecting the project in SoftConsole and hitting Alt+Enter on your keyboard. -
Navigate to C/C++ Build > Settings > GNU ARM Cross C Linker > General and double-click the linker script file:
-
To ensure the code is programmed to non-volatile memory, change
esram
toenvm
at the very end of the text line in the dialog that appears: -
Still in the Properties window, C/C++ Build > Settings, navigate to GNU ARM Cross C Compiler > Preprocessor.
-
Change the
BOARD_ID
macro for the board you are programming as outlined in the section above (note the escape characters before each double quote): -
Change the
MSP_EXP_ADDR
macro for the board according to thei2c.h
config file under theobcsw
GitLab repository. -
Click the Debug (yes -- Debug!) button in the SoftConsole main window to program the board. The Console window should display information about it programming to NVM. Programming should also take longer than in the case of RAM.
-
End the debug session from SoftConsole's Debug perspective.
-
Move the FlashPro5 programmer from the board you just programmed to the next one you want to program.
-
Repeat steps 4-7.
-
Reset the CUBES stackup by power-cycling the
5V_CUBES
power rail. -
Perform a
REQ_HK
MSP command from each of the two CUBES boards and ensure the readouts "make sense".
IMPORTANT:
-
Revert the
.cproject
file back to its original contents, to ensure you are not unnecessarily programming to NVM next time:git restore .cproject