10
0
Fork 0
mirror of https://gerrit.osmocom.org/simtrace2 synced 2024-08-10 21:16:22 +00:00
simtrace2/firmware
Kévin Redon 7233cf803a initialize VCC, RST, and VCC with actual values
previously the card RST, VCC, and CLK signal states have been initialized with
default values corresponding to an inactive reader.
this worked fine for actual inactive readers since the default values match
and would be updated when the signal changes (edge detection).
but if the reader is in another state, card activation detection could fail.
this is fixed since the actual signal values are now used during initialisation.

at the same time I changed the variable type from uint8_t to boolean since they
have only two possible states, and understanding the actual state when coding
is simpler (no need to check which integer corresponds to which state).

this change has been successfully tested on the 2 slots of OWHW board.

Change-Id: Ie9245d75d48ae93d16f97897d4fa5ad6cd402e73
2019-11-14 19:54:17 +01:00
..
apps add/fix mcp23017 i2c gpio expander functions and tests 2019-10-24 18:09:05 +02:00
atmel_softpack_libraries gcc: fix warning 2018-08-06 16:23:33 +02:00
libboard add/fix mcp23017 i2c gpio expander functions and tests 2019-10-24 18:09:05 +02:00
libcommon initialize VCC, RST, and VCC with actual values 2019-11-14 19:54:17 +01:00
libosmocore add libosmcore utilities 2018-08-04 11:16:15 +02:00
openocd Renamed main folder to firmware 2015-04-07 18:24:06 +02:00
test initialize VCC, RST, and VCC with actual values 2019-11-14 19:54:17 +01:00
usbstring add missing usbstring.c 2017-03-07 15:51:49 +01:00
Makefile publish: also upload latest 2019-08-01 17:23:23 +02:00
README.txt add new board and app for gpio testing on octsimtest board 2019-07-30 10:56:51 +02:00
TODO.txt Add firmware/TODO.txt that was not committed so far 2018-05-11 15:49:31 +02:00

This is the source code for SIMtrace 2 firmwares.

= Hardware

== Micro-Controller

The firmware is for Microchip (formerly Atmel) ATSAM3S4B micro-controllers (MCU).
Product page:  https://www.microchip.com/wwwproducts/en/ATSAM3S4B
Datasheet: http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-6500-32-bit-Cortex-M3-Microcontroller-SAM3S4-SAM3S2-SAM3S1_Datasheet.pdf

Note: The SAM3S is now not recommended for new designs.
It can be replaced by the pin-compatible SAM4S.
The MCU can be specified using the environment variable `CHIP` (set to `sam3s4` per default) for future MCU support.

== Boards

The SIMtrace 2 firmware supports multiple boards.
A board defines a given circuit board.
While compiling the firmware, set the target board using the `BOARD` environment variable (set to `qmod` per default).
The supported boards correspond to sub-folders under `libboard`.

Current boards supported are:

* `simtrace`: The good old Osmocom SIMtrace PCB with SAM3 instead of SAM7, open hardware.
* `qmod`: A sysmocom-proprietary quad mPCIe carrier board, publicly available
* `owhw`: An undisclosed sysmocom-internal board, not publicly available
* `octsimtest`: A sysmocom-proprietary production testing board, not publicly available

= Firmware

== Library

The firmware uses the manufacturer provided Software Package (SoftPack) micro-controller library.
The original library is available at https://www.microchip.com/design-centers/32-bit/softpacks/legacy-softpacks .
Version 2.1 from 2001 is used: http://ww1.microchip.com/downloads/en/DeviceDoc/SAM3S_softpack_2.1_for_CodeSourcery_2010q1.zip
The SIMtrace 2 project uses the `libboard_sam3s-ek`, `libchip_sam3s`, and `usb` sub-libraries, saved in `atmel_softpack_libraries` (with local modifications).

Note: SoftPack is the legacy micro-controller library.
This library is now replaced by the Advanced Software Framework (ASF): https://www.microchip.com/avr-support/advanced-software-framework-(asf) .
The SAM3S ASF documentation is available at http://asf.atmel.com/docs/latest/sam3s/html/index.html .

== Applications

An application is a specific piece of software with given functionality.
While compiling the firmware, set the target application using the `APP` environment variable (set to `dfu` per default).
The supported applications correspond to sub-folder under `apps`.

Current applications supported are:

* `dfu`: The USB DFU bootloader to flash further main appliction firmwares.
* `ccid`: To use SIMtrace 2 as USB CCID smartcard reader.
* `cardem`: To provide remote SIM operation capabilities.
* `trace`:  To monitor the communication between a SIM card and a phone (corresponds to the functionality provide by the first SIMtrace)
* `triple_play`: To support the three previous functionalities, using USB configurations.
* `gpio_test`: internal test code

== Memories

Firmwares can be run from several memory locations:

* flash: Run natively from start of flash memory
* dfu: Run after a DFU bootloader from an offset after the first 16k of flash (the first 16k are reserved for the bootloader)
* ram: Run from within the RAM of the chip, downloaded via JTAG/SWD

== Building

A given firmware build is made for a specific combination of an application `APP` running in a certain memory `MEM` on a given board `BOARD`.
When building using `make`, set the target application using the `APP` environment variable and target board using the `BOARD`  environment variable, e.g.:

* make APP=cardem BOARD=qmod
* make APP=dfu BOARD=qmod

The Makefile will create output files in the format: `bin/$(BOARD)-$(APP)-$(MEM).{elf,bin}`

The level of debug messages can be altered at compile time:
```
$ make TRACE_LEVEL=4
```
Accepted values: 0 (NO_TRACE) to 5 (DEBUG)

The qmod specific option `ALLOW_PEER_ERASE` controls if the UART debug command to assert the peer SAM3S ERASE line is present in the code.
Per default this is set to 0 to prevent accidentally erasing all firmware, including the DFU bootloader, which would then need to be flashed using SAM-BA or JTAG/SWD.
Setting `ALLOW_PEER_ERASE` to 1 enables back the debug command and should be used only for debugging or development purposes.

= Flashing

To flash a firmware image follow the instructions provided in the [wiki](https://projects.osmocom.org/projects/simtrace2/wiki/).