Commit Graph

157 Commits

Author SHA1 Message Date
Kevin Redon ba3a2fa250 switch UART_debug to ASYNC
using the synchronous HAL library causes RX overflow after 5 bytes
on bulk incoming data (e.g. pasted).
this mainly due to printing synchronously the character, but to
further prevent congestion we switch to asynchronous (e.g.
interrupt driven) communication.

The RX part works great now (no overflow), but the TX part is
malfunctioning because the HAL Async library does not buffer the
data to be transmitted and expects it to be in memory until
the transmission is complete (which printf does not do).

This change will not be reflected in Atmel START since it does not
allow to set the underlying STDIO redirect peripheral to async.

Change-Id: If18883e96f336aa9f6b11607859260da5e1503c7
2019-04-18 17:27:20 +02:00
Harald Welte 077258163f sim-atr: Print slot number when printing ATR
Change-Id: Iafb957f551de1239f63360854fabeecfeb62b530
2019-04-17 17:33:17 +02:00
Harald Welte dcf5783424 sim-atr command: enable the LED when the command is active.
Change-Id: I50c125d46233e86003cc14ec9b5bac47127e8776
2019-04-17 17:33:17 +02:00
Kevin Redon 70b867a64a remove SWO pin initialisation
using the SWO signal on TX has the advantage of being able to
have printf debug while still using SERCOM7 in ISO7816 mode for
the SIM card, but it has two drawbacks:
- SWO outputs data only if a debug session is ongoing (e.g. a SWD
debugger is connected). this saves output processing when no SWD
is connected, but it is not possible to force output without
having an SWD debugger connect (confirmed by Microchip help),
which is not convenient for simple UART debugging.
- no input is possible (SWO can only output).

Thus instead we will still use SERCOM7 for UART debug, allowing
commands to be input.
SERCOM7 should only be used for UART debug when no card in present
in SIM7.
This check in not yet implemented.

Change-Id: I199d6e356129526e65d5d1075a264eb35904d099
2019-04-17 12:06:11 +02:00
Kevin Redon a562a1437f update ASFv4 library to 1.0.1465
Change-Id: I828e87c7ededbb50a999d672cf0b738eef9a093a
2019-04-17 12:06:11 +02:00
Kevin Redon 0bc0d74e88 update CMSIS to 5.1.2
this changes comes from Atmel START

Change-Id: Ib9b00107836c1604c7169d69ba607fead8c55355
2019-04-17 12:06:11 +02:00
Kevin Redon 18c2dbbb15 minor: update atmel start project configuration
Change-Id: I8e719f1687befb9a3657a2e582165dec3cd00094
2019-04-17 12:06:11 +02:00
Harald Welte 34fabacbf6 command.c: don't print "unknown command" for empty commands
Change-Id: If8512a705e464a9cae949e6278a8d69eb7833737
2019-04-17 12:06:00 +02:00
Kevin Redon c89bb8cd79 add sim-atr command
the sim-atr command resets the card and read the resulting
answer to reset.

Change-Id: I30b284cab60a50d4cd3080f46f4d332193bbf1ee
2019-04-17 12:06:00 +02:00
Kevin Redon 37e5fa913b change SERCOM clock to 3.3 MHz
we use the SERCOM peripheral for USART (in 7816 mode SIM card
communication) in synchronous mode (TX and RX clock are the same).
in this mode only the 8 least significant bits of the BAUD register
are used (see TRM 33.6.2.3 Clock Generation – Baud-Rate Generator).
When the SERCOM is clocked at 100 MHz the minimum resulting baud
rate would be 100E6 / (2 * 255 + 1) = 195694 bps.
clocking SERCOM at 3.33 MHz also to have a baud rate of 6720 bps
(~ 3.33E6 / (2 * 247 + 1)), used after reset to read the ATR.

Change-Id: Id60322e092a6652a89821fc737d5336d79a1420c
2019-04-17 11:52:00 +02:00
Kevin Redon ee4912966b change ISO baud rate default to 6720 bps
the ISO7816 I/O baud rate is f / (Fd / Dd), with Fd 372, Dd = 1.
f_max is 4 MHz, but we will use the minimum 20 / 8 = 2.5 MHz,
thus the baud rate after reset will be 6720 bps.

Change-Id: I9165575404f070c7429daaa3593838d08a5c5e10
2019-04-17 11:52:00 +02:00
Kevin Redon 4be5276743 minor: improve documentation
Change-Id: I250209d45a57c5ad7d1265a68aa71fc31ec06f69
2019-04-17 11:52:00 +02:00
Kevin Redon 0c7ea79dcf remove example code
as the code will use alternative libraries, the examples will not
be able to compile anymore.
plus they are not required for the firmware and the example code
can be downloaded from Atmel start.

Change-Id: If53df47089de9eb8498734c19d6a0420c1e79031
2019-04-17 11:06:20 +02:00
Harald Welte 61dad9145f jenkins.sh: use PARALLEL_MAKE to accelerate build speed
Change-Id: Idb75e028d52803e3f8685d42c584f8f96613ec3c
2019-04-17 08:58:51 +00:00
Kevin Redon c94e0fc0e6 add ASFv4 M2M (memory-to-memory DMA) middleware
This is form Atmel Start and provides functionality for hardware-based
DMA copies from memory to memory.

Change-Id: Ib07755b2c5974af70817f5460fb0f358c631452a
2019-04-17 10:25:09 +02:00
Kevin Redon 6ddca8b488 minor: remove unnecessary hello world command
Change-Id: I414b2ddd0bacff692316fe212b9d3b506100a7ba
2019-04-17 10:24:03 +02:00
Kevin Redon b40c3ee903 minor: fix typo
Change-Id: I57c743250af19713e7438606bc1c737cfe0c383c
2019-04-17 10:24:03 +02:00
Harald Welte 67b2abacd2 manual_test.c: New manual board testing mode
Change-Id: I8fc94fa08521224eff79d0aa9d7b42ceeaa760c9
2019-04-16 21:13:48 +02:00
Harald Welte 1762506a1f ncn8025: Invert the software logic of RSTIN
In hardware, the Card RST pin is low-active.  There's a level
translator in the NCN8025, but there's no logic inversion, so RSTIN
is also low-active.  In software, we have the policy of all signals
being "true-active", i.e. true represents the active state, and false
the inactive state.

Hence, we must invert the logic of how we handle rstin.

Change-Id: Ia45246b7517b2e6ecb01d22b3af52aee7a51de64
2019-04-16 21:11:40 +02:00
Harald Welte e7aa534355 command.c: Print prompt when starting up
Change-Id: I18e4351609ab10c06a2fa197cb9f7a66269799a0
2019-04-16 21:11:40 +02:00
Harald Welte 255da5ed24 main.c: Call ncn8025_init also for SIM7
The ncn8025 has no impact on the UART, so no matter if we use
SERCOM7 as debug uart or as SIM UART, we can always initialize
the NCN8025 and thereby allow control of (e.g.) the LED.

Change-Id: I70ae1e050d5540627bc77626dbf1b6040e95dae4
2019-04-16 18:20:53 +02:00
Harald Welte 5af7c8c36b ncn8025: Add support for reading SIMx_INT status
Change-Id: Iab9edc1214bb22ee304daa834fd9e2376d42c97c
2019-02-27 13:46:46 +00:00
Harald Welte 1b9a5b8125 Add various SIM card related debug command
this allows commands like
 sim-status 0		# read the status
 sim-voltage 0 5	# set voltage to 5V
 sim-clkdiv 0 2		# set clock-divider to 2 (10 MHz)
 sim-reset 0 0		# disable reset
 sim-power 0 1		# enable power

Change-Id: Id6131be60d37cba769c79952fa44f3ec6c976a38
2019-02-27 13:44:28 +00:00
Harald Welte ff9f4ceca9 Add mnimalistic command line interface "command.c"
This is a very simplistic command line interface parser which
various parts of the code can use to register textual commands
on the debug UART.

Change-Id: I2d289228fb97ecde5602e9756f3d7c51fa65a3b7
2019-02-27 13:42:27 +00:00
Kevin Redon 3c045b29ce minor: rename MUX_SSTAT to MUX_STAT
Change-Id: I5eee17de31fdce92346641772fc0c63d4c37507a
2019-02-27 13:22:33 +00:00
Harald Welte 361ed2072b Switch SERCOM7 (Debug UART) to sync mode + add STDIO
this will allow us to do printf()

Change-Id: Ibf4ba961d4bbf8d787558f38f3d557422587aad3
2019-02-27 13:17:17 +00:00
Kevin Redon d0903f7e51 fix ASFv4 USB stack
this ASFv4 USB library change fixes USB transfer.
two transfer-size issues existed:
- on multi-packet transfer if the last packet was less than the
USB transfer packet size, the packet would be received but not
acknowledged
- during normal transfer the packet size of a previous packet set
the size of the current packet, ignoring the actual transfer size

Change-Id: I4209072ee808f0e246bcd5e86917dcf1d213c26b
2019-02-26 23:06:42 +00:00
Harald Welte 93f628a4c3 PA11: Increase drive strength to 8mA
It has been observed that the 20 MHz clock signal doesn't even remotely
resemble a square shape unless DRVSTR=1 is set using this patch.

Change-Id: I1366e13442eda829756aa4121be81eb15135c73e
2019-02-24 23:05:15 +01:00
Harald Welte f53f226765 Enable cache via CMCC for higher performance
Change-Id: I7a243a8d964fea3d3decc6c73c16e07036e4ee93
2019-02-24 23:05:15 +01:00
Harald Welte 092494ef77 Update from AtmelStart: Define all used GPIO pins
Change-Id: I2cb67fd01f6e8602af16bbdb4960427586cdd9a4
2019-02-24 23:05:15 +01:00
Harald Welte 863ea296d9 update from Atmel Start (just loading + re-exporting the project)
Change-Id: I59b2442a95871b8052bfdfdac6d77a7207d8b70a
2019-02-24 23:05:15 +01:00
Harald Welte c3f170d214 Support for sysmoOCTSIM NCN8025/SX1503 control
This adds an I2C bit-banging layer, defines the four busses on the
sysmoOCTSIM and adds some high-level functions to control the NCN8025
for each SIM slot.

Change-Id: Ic5287cf80d2be2070c504e9d40f7c6fc0d37d8b9
2019-02-24 23:05:15 +01:00
Kevin Redon 9c85463b1a add README file
Change-Id: I9286493e4e2d20f00a33e7b565adde10198f179a
2019-02-07 16:50:47 +01:00
Kevin Redon e4c9a177de add GPLv2 license
Change-Id: I761b3af3db43aa0da679c2f83aa89c92a7aae668
2019-02-07 16:23:30 +01:00
Kevin Redon eff5cb52c5 relocate application to after the DFU bootloader
without this relocation the DFU bootloader can jump to the
application but following executed code would not be the one from
the application.

Change-Id: Ieeefcf80918fd10e48debab6ff08505f6588811c
2019-02-07 15:56:05 +01:00
Kevin Redon d7dfb6e38b add debug welcome message output
Change-Id: I8dde644caa56152b17da674e187006726991ff9c
2019-02-07 15:56:05 +01:00
Kevin Redon 1f8ecefe65 add ISO7816 peripherals
configure SERCOM 0 to 6 peripherals to communicate using the
ISO7816 T=0 protocol.
SERCOM7 should be for the 8th SIM card, but for now it is used as
UART debug output.
Auto-detection between SERCOM for the 8th SIM and debug UART will
be done later.

Change-Id: I3f1411ec5bc2ed7dfa714550d041f52be665132a
2019-02-07 15:56:05 +01:00
Kevin Redon 6a8295cfa9 name pin according to schematic
Change-Id: I94a7f2216c288150b044a6190804f9b7247eb10c
2019-02-07 15:56:05 +01:00
Kevin Redon d4ed1ec9ff add 20 MHz clock output
use GCLK5 to output 20 MHz clock on PA11/GCLK_IO[5] for SIM cards
clock.
this can be further divided by the NCN8025 before reaching the SIM.

Change-Id: I2c0d6a31ec63a87e04ef4e3afbedce3a221324cc
2019-02-07 15:56:05 +01:00
Kevin Redon 4e39b0194f switch from dev board to prototype
the SAM E54 Xplained Pro development board uses a SAM E54P20N
micro-controller.
the sysmocom sysmoOCTSIM prototype uses a SAM E54N19A
micro-controller.
the system LED and UART debug GPIO are different, else the code
is the same.
the Atmel START definitions have been updated accordingly.

Change-Id: Ifd15f6759c51b42a8d11b09f9f495d7e7a5b6afc
2019-02-07 15:56:05 +01:00
Kevin Redon 8e5380068c echo back UART input
let main run the main loop instead of the CDC ACM example.
also rename the CDC ACM example functions.

Change-Id: I44b15079672b4058de1fa08365541317d54958dc
2019-02-07 15:56:05 +01:00
Kevin Redon 293c841773 fix DPLL input clock division
Change-Id: I3df1356d36b54d0cc34fd827265b1e4b9d55509f
2019-02-07 15:56:05 +01:00
Kevin Redon 78d2f44754 blink LED on UART activity
Change-Id: Ib230be6003f28931ab4c60228796ec0af6c783d9
2019-02-07 15:56:05 +01:00
Kevin Redon 5908a5ccc6 add system LED definition
Change-Id: I97dc71ac00b64fdd05e0ff4c7e16e1b68b57b695
2019-02-07 15:56:05 +01:00
Kevin Redon ccbed0b1df add SERCOM HAL Async library
Change-Id: I530a5bc5ee7e89149eb251bda0adf7963733d2ee
2019-02-07 15:56:05 +01:00
Kevin Redon e676557550 rename application to main
also remove unused armcc.
only the GCC cross-compiler is used.
the ARMCC Makefile would not be maintained.

Change-Id: Ib6ec525885943afba9b24df88a5bee8009df95b5
2019-02-07 15:56:05 +01:00
Kevin Redon 4cd3f7d163 add SERCOM peripheral for UART debug
currently only the SERCOM peripheral driver is added an configured,
but it is not being used.
UART debug will be done through the EDBG COM port, on PB24/PB25 of
SAM E54 Xplained Pro board

Change-Id: Id7af37ce1dd2d0a356e019c96bf6438ce459411b
2019-02-07 15:56:05 +01:00
Kevin Redon 4cb8e325c8 use XOSC1 directly for DPLL1
DPLL1 can take directly XOSC1 as input and divide it to 2 MHz.
thus the intermediate GCLK11 is not needed.
we now also completely de-configure GCLK11
this configuration is not supported by Atmel START since it does
not know about the division and thinks the input frequency
exceeds the maximum
GCLK2 is also disabled for now because it is not used

Change-Id: Icee7f5a13019c47cebc23376cabb18cb31178ece
2019-02-07 15:56:05 +01:00
Kevin Redon 20abc4f441 set DPLL1 to 100 MHz
use GCLK11 to bring external crystal oscillator XOSC1 from 12 MHz
to 2MHz
use DPLL1 to multiply 2 MHz to 100 MHz.
the division is first needed because the DPLL0 maximum input
frequency is 3.2 MHz
100 MHz is the maximum input frequency for the SERCOM peripherals

Change-Id: I0482c39cc0db999904c585d21738dbce57ca3b55
2019-02-07 15:56:04 +01:00
Kevin Redon 6b9363ca8e remove usage of GCLK11
DPLL0 can take directly XOSC1 as input and divide it to 2 MHz.
thus the intermediate GCLK11 is not needed.
this configuration is not supported by Atmel START since it does
not know about the division and thinks the input frequency
exceeds the maximum

Change-Id: I121ad850cf118b641fe522b513ffd7e00b30b710
2019-02-07 15:56:04 +01:00