Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cellular and Data storage #24

Merged
merged 92 commits into from
Feb 9, 2024
Merged
Changes from 1 commit
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
112698c
Import SpiffsParticleRK and data upload
emilybthorpe Aug 1, 2023
a0fb493
Fix particle connect
emilybthorpe Aug 1, 2023
aad1114
cellular work
emilybthorpe Aug 4, 2023
18a1137
Merge branch 'chargetask' into cellular
emilybthorpe Aug 4, 2023
21ad015
Fix imports
emilybthorpe Aug 4, 2023
5d3579f
Basic cellular working
emilybthorpe Aug 4, 2023
16c89ad
Porting ensembleTypes from v2
emilybthorpe Aug 5, 2023
2d367ac
Clean up ensemble header with comments
emilybthorpe Aug 5, 2023
253136e
more cellular work
emilybthorpe Aug 5, 2023
8106ccb
port over deploy and prereqs from fw2
emilybthorpe Aug 7, 2023
7135d91
port over code for basic data upload/encode
emilybthorpe Aug 7, 2023
12130f5
cellular debugging
emilybthorpe Aug 7, 2023
bfef833
Testing littlefs
emilybthorpe Aug 7, 2023
ae3ce50
implement tests for hasdata and createFile
emilybthorpe Aug 7, 2023
0530b4b
implement getNumFiles
emilybthorpe Aug 7, 2023
1933d3c
remove spiff-fs and replace with particle little-fs
emilybthorpe Aug 8, 2023
f41ae8e
more cellular work
emilybthorpe Aug 8, 2023
de0e6e2
Deploy debugging
emilybthorpe Aug 9, 2023
f366142
Fix recorder attempting to get data from empty file
emilybthorpe Aug 10, 2023
09bebee
Add doxygen
emilybthorpe Aug 10, 2023
b646a8e
Merge branch 'main' into cellular
emilybthorpe Aug 10, 2023
ac07ddd
Add doxygen for system upload command
emilybthorpe Aug 10, 2023
4f472f4
Merge branch 'cellular' of https://github.com/UCSD-E4E/smartfin-fw3 i…
emilybthorpe Aug 10, 2023
7c48b7e
Formatting
emilybthorpe Aug 10, 2023
03df172
remove testing publish
emilybthorpe Aug 10, 2023
c882ca2
Fix stat not initalizing and therefore causing undefined behavior fix…
emilybthorpe Aug 11, 2023
c06d365
Fix compliation warnings
emilybthorpe Aug 11, 2023
caf98d5
Merge branch 'main' into cellular
emilybthorpe Aug 21, 2023
d358311
Merge branch 'main' into cellular
emilybthorpe Aug 28, 2023
b91a234
feature: get data from sensor instead of fake data
emilybthorpe Aug 28, 2023
7fd2a80
Merge branch 'main' into cellular
emilybthorpe Aug 29, 2023
5180cd6
feature: integrate temp sensor to data collection
emilybthorpe Aug 29, 2023
ee29c9e
Merge branch 'main' into cellular
Sep 11, 2023
770cb2b
fix: Removes SpiffsParticleRK dependency
Sep 11, 2023
563e2e3
fix: Fixes newlines
Sep 11, 2023
409c7c4
fix! switches to 32 bit param, adds opendir fail
Sep 11, 2023
82ca64c
feat!: Adds fileCLI
Sep 11, 2023
6154c5b
fix: Reduces flog entries to 128
Sep 12, 2023
b74b46d
fix: Fixes tooling paths and switches to c++11
Sep 12, 2023
bd0ae1e
fix: Includes
Sep 12, 2023
3c80ff7
chore: Adds ruler
Sep 12, 2023
32349fe
fix: Adds debug point flog
Sep 12, 2023
66475c7
feat: Adds ls functionality
Sep 12, 2023
621797d
style: Fixes long line
Sep 12, 2023
3422dcb
fix: Adds chgdir
Sep 12, 2023
d35ff05
feat: Adds cd and pwd
Sep 12, 2023
08ad4c4
feat: Adds rm, fixes buildpath
Sep 12, 2023
6344465
feat: Adds hexdump
Sep 12, 2023
263381a
feat: Added file publish dump
Sep 12, 2023
c2cfcd5
feat: Adds helptext
Sep 12, 2023
be37dac
fix: Updates helptext
Sep 12, 2023
4cab8a3
style: Formatting
Sep 12, 2023
c41fe78
fix: Updates base85 to latest
Sep 12, 2023
eccb68f
docs: Updates library register
Sep 12, 2023
825e778
fix: Rolling back base85
Sep 12, 2023
afa0351
docs: Adds Recorder class
Sep 21, 2023
1f58ab3
feat: Switches to consolidated menu system
Sep 22, 2023
56c243a
fix: Fixes sleep CLI
Sep 22, 2023
f23356f
fix: Fixes upload CLI
Sep 22, 2023
cb0da06
fix: Fixes includes
Sep 22, 2023
47a6bd8
fix: Updates hexdump
Sep 23, 2023
cd1effd
feat: Functional session
Sep 27, 2023
86a4b45
fix: Updates flog
Sep 27, 2023
4d6f328
fix: Fixes data location initialization
Sep 27, 2023
f641578
feat: Adds mkdir
Sep 27, 2023
24cafec
fix: Added FLOG include
Sep 27, 2023
a9eb5e9
feat: Adds basic recorder functionality and test
Sep 29, 2023
815c6a1
fix: Fixes current_dir level
Sep 29, 2023
e3cc6a5
fix: Removes setName
Sep 29, 2023
1cdb02b
feat: Adds setSessionTime
Sep 29, 2023
b773e64
docs: Fixes environment
Oct 13, 2023
cf7b70e
feat: Adds fsync to write
Oct 13, 2023
9198bb1
docs: Adds more docs
Oct 13, 2023
98de874
feat: Adds additional fs flog entries
Oct 13, 2023
a2f5a6d
chore: Removes old debug flog
Oct 13, 2023
6a574c0
feat: Adds packetizing
Oct 13, 2023
a296ff0
feat: Adds pop last packet debug
Oct 13, 2023
654abd5
fix: Pops on empty session
Oct 13, 2023
dc66939
feat: Adds error handling to creation
Oct 13, 2023
63b10dd
fix: Adds protection against double open
Oct 13, 2023
ab59ef8
feat: Completes recorder
Oct 13, 2023
5a5f745
docs: Updates service diagram
Oct 17, 2023
c7cac65
chore: Ignores plantuml output
Oct 17, 2023
3502cc2
docs: Updated diagram
Oct 19, 2023
45b392e
docs: Ignores firmware diagram output
Oct 19, 2023
7339458
fix: Enabled cloud connectivity commands
Oct 19, 2023
8720114
fix: Cleaned up flog entries
Oct 19, 2023
8a3bd5e
docs: Updated application progress
Oct 19, 2023
2adc537
feat: Adds firmware hashes
Oct 19, 2023
674701e
feat: Adds DeviceOS version display
Oct 19, 2023
d2b7868
feat: Adds publish_blob
Feb 9, 2024
4774141
Merge branch 'main' into cellular
ntlhui Feb 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Import SpiffsParticleRK and data upload
emilybthorpe committed Aug 1, 2023
commit 112698c42a699b10d57f884211fe17463b3629d6
21 changes: 21 additions & 0 deletions lib/SpiFlashRK/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 rickkas7

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
175 changes: 175 additions & 0 deletions lib/SpiFlashRK/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
# SpiFlashRK

*Particle library for SPI NOR flash memory chips*

This library provides access to SPI NOR flash chips on the Particle platform. It's a low-level access that allows byte-level write-to-0 and sector-level erase-to-1.

You probably won't use this library directly; it's intended by be used as the hardware interface for a library that provides easier access, wear-leveling, flash translation, etc.. I recommend the SpiffsParticleRK library.

The full browsable API documentation can be found [here](http://rickkas7.github.io/SpiFlashRK/).

## Instantiating an object

You typically instantiate an object to interface to the flash chip as a global variable:

```
SpiFlashISSI spiFlash(SPI, A2);
```

Use an ISSI flash, such as a [IS25LQ080B](http://www.digikey.com/product-detail/en/issi-integrated-silicon-solution-inc/IS25LQ080B-JNLE/706-1331-ND/5189766). In this case, connected to the primary SPI with A2 as the CS (chip select or SS).

```
SpiFlashWinbond spiFlash(SPI, A2);
```

Use a Winbond flash, such as a [W25Q32](https://www.digikey.com/product-detail/en/winbond-electronics/W25Q32JVSSIQ/W25Q32JVSSIQ-ND/5803981). In this case, connected to the primary SPI with A2 as the CS (chip select or SS).

```
SpiFlashWinbond spiFlash(SPI1, D5);
```

Winbond flash, connected to the secondary SPI, SPI1, with D5 as the CS (chip select or SS).

```
SpiFlashMacronix spiFlash(SPI1, D5);
```

Macronix flash, such as the [MX25L8006EM1I-12G](https://www.digikey.com/product-detail/en/macronix/MX25L8006EM1I-12G/1092-1117-ND/2744800). In this case connected to the secondary SPI, SPI1, with D5 as the CS (chip select or SS). This is the recommended for use on the E-Series module. Note that this is the 0.154", 3.90mm width 8-SOIC package.


```
SpiFlashP1 spiFlash;
```

This is the external flash on the P1 module. This extra flash chip is entirely available for your user; it is not used by the system firmware. You can only use this on the P1; it relies on system functions that are not available on other devices.


## Connecting the hardware

For the primary SPI (SPI):

| Name | Flash Alt Name | Particle Pin | Example Color |
| ---- | -------------- | ------------ | ------------- |
| SS | CS | A2 | White |
| SCK | CLK | A3 | Orange |
| MISO | DO | A4 | Blue |
| MOSI | D1 | A5 | Green |


For the secondary SPI (SPI1):

| Name | Flash Alt Name | Particle Pin | Example Color |
| ---- | -------------- | ------------ | ------------- |
| SS | CS | D5 | White |
| SCK | CLK | D4 | Orange |
| MISO | DO | D3 | Blue |
| MOSI | D1 | D2 | Green |

Note that the SS/CS line can be any available GPIO pin, not just the one specified in the table above.

- Electron using Primary SPI

![Electron](images/electron.jpg)

- Photon using Secondary SPI (SPI1)

![Photon SPI1](images/spi1.jpg)

- Photon using Primary SPI and a poorly hand-soldered 8-SOIC adapter

![SOIC Adapter](images/soic.jpg)



## The API

The API is described in the SpiFlashRK.h file. But you will rarely need to use the low-level API directly.
## Members


#### `public void `[`begin`](#class_spi_flash_base_1ac15f0d887b3f63e95c38fa07ad27b4ad)`()`

Call begin, probably from setup(). The initializes the SPI object.

#### `public bool `[`isValid`](#class_spi_flash_base_1a1a556af53af5b4a535091ac48ccddf9d)`()`

Returns true if there is a flash chip present and it appears to be the correct manufacturer code.

#### `public uint32_t `[`jedecIdRead`](#class_spi_flash_base_1aaafb065389237c90ed89ea61a1992743)`()`

Gets the JEDEC ID for the flash device.

#### Returns
A 32-bit value containing the manufacturer ID and the two device IDs:

- byte[0] manufacturer ID mask 0x00ff0000
- byte[1] device ID 1 mask 0x0000ff00
- byte[2] device ID 2 mask 0x000000ff

#### `public void `[`readData`](#class_spi_flash_base_1a053c787ed441aee2830629cf077ed3b4)`(size_t addr,void * buf,size_t bufLen)`

Reads data synchronously. Reads data correctly across page boundaries.

#### Parameters
* `addr` The address to read from

* `buf` The buffer to store data in

* `bufLen` The number of bytes to read

#### `public void `[`writeData`](#class_spi_flash_base_1ac47ed89cd11ad72a1e877c59cf3e2ab7)`(size_t addr,const void * buf,size_t bufLen)`

Writes data synchronously. Can write data across page boundaries.

#### Parameters
* `addr` The address to read from

* `buf` The buffer to store data in

* `bufLen` The number of bytes to write

#### `public void `[`sectorErase`](#class_spi_flash_base_1abcab7312a96d40530981b06199b7dc9c)`(size_t addr)`

Erases a sector. Sectors are sectorSize bytes and the smallest unit that can be erased.

This call blocks for the duration of the erase, which take take some time (up to 500 milliseconds).

#### Parameters
* `addr` Address of the beginning of the sector. Must be at the start of a sector boundary.

#### `public void `[`chipErase`](#class_spi_flash_base_1a22edd97067f1783351a4ee542c792007)`()`

Erases the entire chip.

This call blocks for the duration of the erase, which take take some time (several secoonds). This function uses delay(1) so the cloud connection will be serviced in non-system-threaded mode.

#### `public inline size_t `[`getPageSize`](#class_spi_flash_base_1aebe4fbac5fbc17289682445968c4cd04)`() const`

Gets the page size (default: 256)

#### `public inline `[`SpiFlashBase`](#class_spi_flash_base)` & `[`withPageSize`](#class_spi_flash_base_1a15345e20dd9986ef96b53e4cb86bf5b6)`(size_t value)`

Sets the page size (default: 256)

#### `public inline size_t `[`getSectorSize`](#class_spi_flash_base_1a67d9998c73e8e4b8afe78b445516f745)`() const`

Gets the sector size (default: 4096)

#### `public inline `[`SpiFlashBase`](#class_spi_flash_base)` & `[`withSectorSize`](#class_spi_flash_base_1a36a4e723f2acdd6fa4fb17b6d6e23d34)`(size_t value)`

Sets the sector size (default: 4096)

## Version History

### 0.0.9 (2020-10-30)

- Increased Macronix chip erase timeout from 6000 to 240000 ms to deal with larger chips (like the MX25L25645G).
- Add support for 4-byte addressing mode for chips larger than 128 Mbit (16 Mbyte). See set4ByteAddressing().

### 0.0.7 (2020-10-29)

- SPI transaction implementation fixed to use actual beginTransaction()/endTransaction() for compatible with multiple SPI devices.

### 0.0.6 (2020-05-04)

- Fix compiler error for undefined conversion to SpiClass with 1.5.1-rc.1.
Loading