Commit graph

19193 commits

Author SHA1 Message Date
d427b9a23d u2f: moved the keys to storage. 2018-03-11 17:40:53 +01:00
ecb44c3c30 sfs: fixed multi-page writing. 2018-03-11 17:40:21 +01:00
b9aaaf3572 Implemented auth 2018-03-11 13:33:10 +01:00
bc8e2a02ae fs: create a new flash filesystem 'SFS'.
SFS is a small filesystem designed for saving limited size files in
page based flash such as that often found in a SoC.  It's best suited
for applications that write up to a hundred small files of a similar
size which are also similar to the flash page size.

Compared to NFFS, SFS:

- Is much smaller
- Doesn't need byte erasable flash

Compared to FCB, SFS:

- Implements the fs API
- Doesn't need byte writable flash

Signed-off-by: Michael Hope <mlhx@google.com>
2018-03-10 22:23:10 +01:00
68a2262711 crc: make crc8_ccitt() match the other CRC functions.
This is a minor change that makes the data pointer const and shifts
the length to a size_t to match the other CRC functions.

Signed-off-by: Michael Hope <mlhx@google.com>
2018-03-10 22:20:18 +01:00
8dbb4c7b2e Started implementing authenticate 2018-03-10 15:03:53 +01:00
13c2cf68b1 Better prng 2018-03-10 14:30:54 +01:00
60c1b8bdbc split out into different files, refactored.
Signed-off-by: Michael Hope <mlhx@google.com>
2018-03-08 22:19:29 +01:00
6f37286aae u2f: hack: can register, parse authenticate.
Signed-off-by: Michael Hope <mlhx@google.com>
2018-03-07 22:54:07 +01:00
d9130dfe08 netusb: move the drop-extra-byte logic to the ECM driver. 2018-02-26 20:52:00 +01:00
1351d94285 netusb: wait for the transfer to complete before retrying.
In the same way as cdc_acm, set a semaphore in the transfer complete
interrupt and wait for it in the main loop before retrying.

This fixes a bug with >= 64 byte frames when logging is off.  If
logging is on, then the time to print logging is enough for the
transmit to complete.  If logging is off, then the 10 retries complete
quickly and try_write() gives up.

Signed-off-by: Michael Hope <mlhx@google.com>
2018-02-25 21:25:29 +01:00
0b235fcc9e netusb: always shrink the packet to match the IP header.
This fixes a bug in the cdc_ecm Ethernet over USB driver.  The ECM
spec (section 3.3.1) says that the end of an Ethernet frame is marked
using the USB short packet mechanisim, where the last packet is less
than the maximum packet size.  If the Ethernet frame is a multiple of
the USB maximum packet size then a final zero length packet must be
sent.

However, Linux sends a one byte packet instead (usbnet.c:1393) to work
around hardware issues with zero length packets.

The current Zephyr driver works most of the time except when you send
an Ethernet frame of the right length where the last byte is zero,
such as:

$ ping 192.0.2.1 -s 23 -p 0

Zephyr then drops the last byte, creating a short frame which gets
dropped higher up in the stack.

Signed-off-by: Michael Hope <mlhx@google.com>
2018-02-25 21:25:14 +01:00
27a279837d cdc_acm: fix interrupt handling, API registration, and propgate errors.
As per uart_pipe.c, irq_is_pending should only return true if any
*unmasked* interrupts are pending.

The device_get_binding() code only checks devices that have an API.
Set the API at compile time so that other devices can refer to the CDC
ACM driver.

usb_write() may return EBUSY if the endpoint is full.  Propagate this
for future use.

Signed-off-by: Michael Hope <mlhx@google.com>
2018-02-25 15:46:44 +01:00
ccaff07a4a slip: increase the RX batch size and fix a bug when in non-TAP mode.
Read up to an (arbitrary) 32 bytes at once from the port.  This improves
performance with the USB CDC ACM driver which may have 64 bytes
available at a time.

Signed-off-by: Michael Hope <mlhx@google.com>
2018-02-25 15:42:31 +01:00
d851be865f uart_pipe: re-work the RX function to match the API and work with USB.
include/uart.h says that an interrupt may be an edge or a level.
Re-work the uart_pipe interrupt handler to support both.  This makes
uart_pipe work with the USB CDC ACM driver.

Signed-off-by: Michael Hope <mlhx@google.com>
2018-02-25 15:39:16 +01:00
61f57df483 drivers/console: fix a null pointer exception on end-of-line.
The previous code is equivalent to:

if !isprint:
  if is carriage-return:
    post line
    set current line to NULL
store ch in current line (*)

which causes a null pointer fault when receiving a carriage return.

This patch switches to a single condition tree.  The side effect is
that other non-printable characters are dropped.

Signed-off-by: Michael Hope <mlhx@google.com>
2018-02-25 13:41:55 +01:00
4e3aad36d9 boards: add the onboard RGB LED to the Trinket M0 DTS.
The Trinket M0 has an on-board APA102 LED connected to SPI1.  Add to
Device Tree, the fixup, and enable the driver.

Signed-off-by: Michael Hope <mlhx@google.com>
2018-02-23 21:48:09 +01:00
81abbba935 Merge branch 'spi_dt' into trinket_dev 2018-02-23 21:38:44 +01:00
d4fd36b231 Merge branch 'upstream_usb' into trinket_dev 2018-02-23 21:38:06 +01:00
cc219a5927 samples: create a USB to serial adapter. 2018-02-23 21:36:05 +01:00
0ce286282e uart: sam0: support setting the baud rate at runtime.
Implements the set line control API for baud rate only.  The SAM0
doesn't implement flow control in hardware.

Signed-off-by: Michael Hope <mlhx@google.com>
2018-02-23 21:36:05 +01:00
b79b64c162 boards: move SPI on the Arduino Zero and Trinket to DTS.
This moves SPI4 on the Zero and SPI1 on the Trinket.

Signed-off-by: Michael Hope <mlhx@google.com>
2018-02-23 21:28:38 +01:00
11ed1e1faf spi: sam0: use Device Tree for configuration.
Define a Device Tree binding for the SAM0 SPI and use it instead of
Kconfig for enabling / disabaling instances

Signed-off-by: Michael Hope <mlhx@google.com>
2018-02-23 21:24:59 +01:00
2119080371 boards: document and enable USB on the Arduino Zero.
Tested on the cdc_acm and netusb samples.

Signed-off-by: Michael Hope <mlhx@google.com>
2018-02-22 20:04:54 +01:00
3b16948a4a usb: sam0: add a USB device driver.
Implements a USB device driver for the SAM0 series.

Signed-off-by: Michael Hope <mlhx@google.com>
2018-02-22 20:04:50 +01:00
Marti Bolivar
94d7afd73f boards: delete misleading comments in flash partitions
The space referred to in these comments was once truly reserved for
the application: no zephyr partition would ever use it.

Now, though, that's not the case, since NFFS will use these sectors
when enabled.

Just delete the comments.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-02-22 18:52:42 +01:00
Marti Bolivar
527e5dabe7 boards: dts: replace comments with links to documentation
Let's point users at the latest documentation on flash
partitions from each of the board files, rather than duplicating some
of the information in it.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-02-22 18:52:42 +01:00
Marti Bolivar
e8e731e53b dts: common.dts: trivial whitespace cleanup
Trivial.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-02-22 18:52:42 +01:00
Marti Bolivar
b7b1dfb8b6 doc: application: re-work DT overlay section
Edits and additions for clarity and correctness, based on the current
contents of the file (dts.cmake) which controls the DTS build.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-02-22 18:52:42 +01:00
Marti Bolivar
137cb01693 doc: flash_partitions: rework
Re-work the flash partitions documentation:

- add sections to provide more complete context

- link to useful information on DT overlays elsewhere in the
  documentation

- touch up some phrasing

- inline a smaller, self-contained example within the page rather than
  linking to an entire board dts

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-02-22 18:52:42 +01:00
Kumar Gala
b328ec51ac cmake: dts.cmake: Use SOC_PATH to find soc/dts.fixup
Per arch the path to the SOC dir that we would find dts.fixup varies
between being ${CONFIG_SOC_FAMILY}/${CONFIG_SOC_SERIES} and just
${CONFIG_SOC}.  The ${SOC_PATH} var handles defining this correct so
use it instead when we define DTS_SOC_FIXUP_FILE.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-02-22 10:14:02 -06:00
Kumar Gala
440cc18d1b cmake: Move SOC_* var defines to cmake/app/boilerplate.cmake
We need access to SOC_PATH in dts.cmake so we need to move the
definitions of SOC_NAME, SOC_SERIES, SOC_FAMILY, and SOC_PATH out of the
toplevel CMakeLists.txt and into cmake/app/boilerplate.cmake.  We place
them before we include cmake/dts.cmake so they will be available to use
in it.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-02-22 10:14:02 -06:00
4f9864b15b boards: add the Adafruit Trinket M0.
The Trinket M0 is a tiny SAMD21 based board with USB, UART, SPI, and
an on-board RGB LED.

Signed-off-by: Michael Hope <mlhx@google.com>
2018-02-22 08:25:39 -06:00
Youvedeep Singh
4d72e48d31 arch: POSIX: Add guard into posix_cheats file.
Some of APIs of POSIX implmentation layer has same name as
native_posix architecture. posix_cheats.h is used to handle this
duplication in API name. Adding a guard in posix_cheats.h based on
CONFIG_PTHREAD_API.

Signed-off-by: Youvedeep Singh <youvedeep.singh@intel.com>
2018-02-21 19:17:28 -05:00
Youvedeep Singh
49fbfbb015 tests: kernel: posix: timer: POSIX timer test.
Added test for POSIX timer APIs.

Signed-off-by: Youvedeep Singh <youvedeep.singh@intel.com>
2018-02-21 19:17:28 -05:00
Youvedeep Singh
8d040f1bcb kernel: POSIX: Compatibility layer for POSIX timer APIs.
This patch provides POSIX timer APIs for POSIX 1003.1 PSE52 standard.

Signed-off-by: Youvedeep Singh <youvedeep.singh@intel.com>
2018-02-21 19:17:28 -05:00
Youvedeep Singh
f0b678b03b tests: kernel: posix: pthread_cancel: POSIX thread cancel test.
Added test for POSIX thread cancel APIs.

Signed-off-by: Youvedeep Singh <youvedeep.singh@intel.com>
2018-02-21 19:17:28 -05:00
Youvedeep Singh
cdaffef883 tests: kernel: posix: pthread: Add pthread test.
This test is POSIX based implementation of tests:kernel:pthread test.
It used POSIX APIs instead of Zephyr APIs.

Signed-off-by: Youvedeep Singh <youvedeep.singh@intel.com>
2018-02-21 19:17:28 -05:00
Youvedeep Singh
2d37286404 tests: kernel: posix: clock: Add posix clock test.
Add posix clock API test.

Signed-off-by: Youvedeep Singh <youvedeep.singh@intel.com>
2018-02-21 19:17:28 -05:00
Youvedeep Singh
2e43d001ea tests: kernel: posix: pthread_join: Add pthread join test.
Implement pthread_join test application.

Signed-off-by: Youvedeep Singh <youvedeep.singh@intel.com>
2018-02-21 19:17:28 -05:00
Youvedeep Singh
7903c84694 kernel: POSIX: removing unused elements from POSIX object attribute.
This patch removes unused member element from POSIX object attributes
(mutex, condition variable and barrier).

Signed-off-by: Youvedeep Singh <youvedeep.singh@intel.com>
2018-02-21 19:17:28 -05:00
Youvedeep Singh
d50b1fe981 kernel: POSIX: Compatibility layer for POSIX clock APIs.
This patch provides POSIX clock APIs for POSIX 1003.1 PSE52 standard.

Signed-off-by: Youvedeep Singh <youvedeep.singh@intel.com>
2018-02-21 19:17:28 -05:00
Youvedeep Singh
1f2e126d4d kernel: POSIX: Compatibility layer for POSIX sleep APIs.
This patch provides POSIX sleep APIs for POSIX 1003.1 PSE52 standard.
sleep(n) is implemented using Zephyr k_sleep API.
uleep(n) is implemented using Zephyr k_sleep/k_busy_Wait API.

Signed-off-by: Youvedeep Singh <youvedeep.singh@intel.com>
2018-02-21 19:17:28 -05:00
Youvedeep Singh
7eabf1025c kernel: POSIX: Compatibility layer for scheduler APIs.
This patch provides scheduler APIs for POSIX 1003.1 PSE52 standard.

Signed-off-by: Youvedeep Singh <youvedeep.singh@intel.com>
2018-02-21 19:17:28 -05:00
Youvedeep Singh
c8aa6570c1 kernel: POSIX: Compatibility layer for pthread APIs.
This patch provides pthread APIs for POSIX 1003.1 PSE52 standard.

Signed-off-by: Youvedeep Singh <youvedeep.singh@intel.com>
2018-02-21 19:17:28 -05:00
Youvedeep Singh
abc94b8597 kernel: POSIX: moving POSIX related typedef into sys/types.h file.
As per POSIX standard typedef should be part of sys/types.h file.
So moving typedef from pthread.h to sys/types.h file.

Signed-off-by: Youvedeep Singh <youvedeep.singh@intel.com>
2018-02-21 19:17:28 -05:00
Youvedeep Singh
325abfbcf4 kernel: POSIX: Fixing return value of POSIX APIs on error.
As per IEEE 1003.1 POSIX APIs should return ERROR_CODE on error.
But currently these are returning -ERROR_CODE instead of ERROR_CODE.
So fixing the return value.

Signed-off-by: Youvedeep Singh <youvedeep.singh@intel.com>
2018-02-21 19:17:28 -05:00
Christopher Collins
f31245d365 subsys: dfu: boot: Remove unused ver query code.
Duplicate code to query was mistakenly added in commit
2ad7ccdb2d.  This code is redundant; the
existing `boot_read_bank_header()` function can read the version from
both image banks.

Signed-off-by: Christopher Collins <ccollins@apache.org>
2018-02-21 18:53:42 -05:00
Kumar Gala
d9bd6909c3 samples: dump_http_server: move generated files into include/generated
Move the generated files into include/generated so they live with the
build and not in the zephyr source tree.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-02-21 18:53:23 -05:00
2e7146b7a6 arch: refactor the SAM0 SoC fixups into a SoC-level file.
This prepares the way for the Trinket M0.

Signed-off-by: Michael Hope <mlhx@google.com>
2018-02-21 16:03:10 -06:00